How do I purge the DreamPress cache?

Caching on DreamPress is done via a Varnish server. The plugin Varnish HTTP Purge is installed on all new and migrated DreamPress installations. This plugin automatically flushes the cache when pages or posts are published.

Manually purging the Varnish cache via the plugin

The Varnish HTTP Purge plugin (included in all DreamPress installs) comes with a Empty Cache button. This button can be found in the main dashboard of WordPress, and clicking it will purge the entire cache. USE THIS SPARINGLY. The whole point of caching is to cache. If you need to selectively purge the cache, you'll still need to do it via SSH for now.

Manually purging the Varnish cache via SSH

A Purge is an HTTP request using the method PURGE. In DreamPress, the request URI can be interpreted in several different ways, one of which is as a Perl Compatible Regular Expression (PCRE). If the URL includes characters that look like a PCRE (for example .*), then it will be treated as a PCRE, so be sure to always include .* if your intention is to purge multiple pages. See the DreamHost Varnish config for more details.

The DreamPress Varnish config uses IP-based Access Control Lists (ACLs) so that the purge request must come from the DreamPress machine. Purge requests from other IPs will show error 405 Not allowed.

To manually purge the Varnish Cache, you must change the DreamPress user to be a shell account, and make use of the curl command-line tool while logged into your domain via SSH.

The following is an example command of how to purge a single CSS file:

[server]$ curl -X PURGE "\.css"

If your site is using www or any other subdomain, you must use the complete domain name in the purge URL. Make sure the domain part matches exactly with what appears when visiting your site.

Note that . (dot) and other PCRE metacharacters need to be escaped if they are present in the path. Do not escape . (dot) characters in the domain name.

If you are making changes to your theme files, or updating themes, an easy way to clear all theme files from your cache would be:

[server]$ curl -X PURGE "*" 

You can also target specific types of files using the following syntax:

[server]$ curl -X PURGE "*\.js"
[server]$ curl -X PURGE "*\.css" 

If the Varnish HTTP Purge plugin is active, you can run the following command to purge the Varnish cache:

[server]$ wp varnish purge

Purging cache manually via SSH with Cloudflare

If you’re using DreamPress behind a proxy like Cloudflare or another firewall service, you need to run a different command.

[server]$ curl -X PURGE "*" -H "host:"

To find your Varnish IP, go to (Panel > 'Domains' > 'Manage Domains') and click on the DNS link beneath the domain. The IP address entry for the www or blank A record is your varnish server. For example:

www A

If you’ve configured DreamPress properly for Varnish, you can use the wp-cli command:

[server]$ wp varnish purge

See also

Did this article answer your questions?

Article last updated .