Sometimes you may need to investigate what is going on inside Varnish. Varnishlog and Varnishstat can give you a lot of useful information regarding your running Varnish. Let’s see what we can do with them.
In case your backend is operating somehow abnormally, something you expected to be cached is not cached, then Varnislog is your best friend.
For example, you can execute:
varnishlog -q "BeReqURL ~c14c4ed8-91a0-4883-809b-258a639d3022"
which filters only backend requests with URLs having the identifier “c14c4ed8-91a0-4883-809b-258a639d3022”.
In case your configured cache storage is not enough or Varnish feels unhealthy, go with Varnishstat which has more than 300 counters. Here are some of them:
- cache_hit – Cumulative number of times a file was served from Varnish’s cache
- cache_miss – Cumulative number of times a file was requested but was not in the cache, and was therefore requested from the backend
- cache_hitpass Cumulative number of hits for a “pass” file
If you know some more ways on how to troubleshoot Varnish, feel free to add them in commentaries.