How do you log the requests that are not getting a cache hit on varnish

varnishWordpress

Made a new theme on WordPress, the new theme is very similar to the old one, meaning there shouldn't be any major SQL queries change, probably less, but the website is slow and it seems it comes from varnish.

How do I debug varnish to see which queries are not getting a cache hit? I am suspecting it's some ajax call, but there are 100 of them, so I need to know which ajax is not getting cached. How do you do that?

Best Answer

For more information about debugging Varnish, I'd like to point to you to the following Varnish Developer Portal article: https://www.varnish-software.com/developers/tutorials/troubleshooting-varnish/#varnish-is-not-caching

In your specific case I'm going to assume the AJAX calls start with /ajax/. With that assumption, you can use the following varnishlog command to debug this:

varnishlog -g request -q "(VCL_call eq 'MISS' or VCL_call eq 'PASS') and ReqUrl ~ '^/ajax/'"

This command will list both cache misses and cache bypasses. The difference is that a miss is just a hit that didn't take place yet, whereas a cache pass will always bypass the cache and will never result in a cache hit.

Related Topic