List contents of varnish cache

varnish

Is there a way to list the contents of the varnish cache storage? Also, it would be nice to somehow list the most frequent cache hits.

I found a way to see the most frequent cache misses by listing what is being sent to the backend with:

varnishtop -b -i TxURL

It would be very useful to see what are my top cache hits URLs.

Best Answer

This answer was originally posted on stackoverflow, and I think it is quite helpful: https://stackoverflow.com/questions/14214104/list-contents-of-varnish-cache

You can use the parameter "Varnish:hitmiss" of varnishncsa.

First capture a sample of logs with:

varnishncsa -F '%U%q %{Varnish:hitmiss}x' -n NAME -w /path/requests.logs

and then:

sort -k 1 /path/requests.logs | uniq -c | sort -k 1 -n -r | head -25

Related Topic