Purging Varnish Cache
If Varnish is enabled for a website, cache can be purged from the terminal or directly through OpenPanel.
Purge from Terminal
You can purge cache entries manually using the curl command.
Purge a Specific URL
This removes a single cached object (for a specific page, image, or file):
curl -X PURGE -H "Host: example.com" http://example.com/wp-content/uploads/test.jpg
Purge a Specific Website
This removes all cached objects for one website (domain):
curl -X PURGE -H "Host: example.com" -H "X-Purge-Method: regex" http://example.com/.*
Purge All Websites
To remove all cached objects across all domains handled by Varnish:
curl -X BAN http://localhost/.*
Alternatively, you can simply restart the Varnish service (see below).
Purge from Crons
To purge cache from a cronjob, simply use the above curl commands and make sure to use varnish/webserver or php for container when creating Crons on OpenPanel.
Purge from WordPress
To purge a cache for a WordPress website, use the CLP Varnish Cache plugin
To configure the plugin:
- Login to wp-admin and go to Settings → CLP Varnish Cache.
- Set varnish as 'Varnish Server'then Enable again.
To purge cache using the plugin:
- Login to wp-admin and go to Settings → CLP Varnish Cache.
- Click on Purge Entire Cache button.
Purge from Terminal
You can purge cache entries manually using the curl command.
Notes
- The
Hostheader is required because Varnish stores cache separately for each domain name. - The
X-Purge-Method: regexheader allows purging multiple URLs using pattern matching. - Purge requests must come from localhost (the website itself or php/webserver containers).