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.
Why should you purge your cache?
When you make changes to your site such as customizing or creating new content, it's possible the old version of your site will be cached. This means the new changes may not show. Purging your cache can help to push your changes live so visitors see the most recent version of your site.
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.
The following is an example command of how to purge a single CSS file:
[server]$ curl -X PURGE "http://example.com/wp-content/themes/mytheme/style\.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.
. (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 "http://example.com/wp-content/themes/.*"
You can also target specific types of files using the following syntax:
[server]$ curl -X PURGE "http://example.com/wp-content/themes/.*\.js" [server]$ curl -X PURGE "http://example.com/wp-content/themes/.*\.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 "http://22.214.171.124/wp-content/themes/mytheme/style*" -H "host:www.example.com"
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 126.96.36.199
If you’ve configured DreamPress properly for Varnish, you can use the wp-cli command:
[server]$ wp varnish purge