Ban & purge
The standard Magento VCL configuration has logic inside the vcl_recv
subroutine to invalidate the cache. This uses the ban
VCL function.
Here's an extract:
if (req.http.host && req.http.host != "" && req.http.host != "127.0.0.1") {
ban("obj.http.X-Host ~ " + req.http.host + " && obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern);
} else {
ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern);}
When changes are made in your backend, and a ban is triggered, you can run the following command to display the so-called ban list:
varnishadm ban.list
This will list all attempts to ban content from the cache, and it uses ban expressions to match patterns of objects.
Please check the ban list. When in doubt, share ban list entries immediately after changing content in the Magento backend. This will allow me to judge whether or not something was wrong.
Debug using the Age header
If it turns out that a ban was successful, the matching objects wil be removed from cache. The Age
response header reflects the age of objects in cache.
A successful ban will result in an Age: 0
header. Please look out for this
Debug using varnishlog
The varnishlog
utility is an in-depth logging tool that gives you insight in what happens to each request.
Run the following command for the page you want to monitor:
varnishlog -g request -q "ReqUrl eq '/'"
Then update some product settings in your backend, and then open the page again. You'll see how Varnish behaves by looking at the logs.
You can also monitor the effectiveness of the ban itself by running the following command:
varnishlog -g request -q "ReqMethod eq 'PURGE'"
The logs will also be quite explicit on what happened to the ban.
When you're having a tough time interpreting the output of these logs, have a look at the blog post I wrote about varnishlog
: https://feryn.eu/blog/varnishlog-measure-varnish-cache-performance/