List contents of varnish cache?

Martin Taleski picture Martin Taleski · Jan 8, 2013 · Viewed 18.8k times · Source

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.

Edit: I am using version: varnish-3.0.3 revision 9e6a70f

Answer

matiasrege picture matiasrege · Jan 9, 2013

I think this you can help:

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