It seems like the stats are accurate, but you want some URLs not to count as misses.
It depends what you mean by requests that are not not cacheable. If there is a URL pattern where you know every URL request will be unique, then why even lookup that URL or enter the backend's response in the cache?
So exclude the URLs you want to discount in a Varnish configuration file like sitename.vcl:
sub vcl_recv {
# Do not cache following pages
if (req.url ~ "^/monitor.*\?heartbeat=") {
return (pass);
}
}
For more information read man vcl
or have a look at the few examples on the Varnish wiki.
Otherwise are they POSTs (automatically not cached), or are they excluded in your .vcl file?
This is not a stats problem. If your vcl_recv()
returns a pass
or an error
, then it shouldn't count as a lookup or a miss (see flowchart here), and your existing calculation is already representative.
From varnishstat -l
, the varnish docs, and from what I see that is able to be graphed in Munin, there is no relevant counter that does anything significantly different from cache_hit or cache_miss.
s_req = client_req = (cache_hit + s_fetch)
s_fetch = cache_miss + s_pass
So 1 - (s_fetch / s_req)
would look like a worse hit rate than you already have, counting passed or 'uncacheable' pages as misses if it doesn't already.
(Incidentally, if you change the backend for the 'uncacheable' page, then I don't think Varnish has counts for requests per backend.)
Silly idea: you could run logtail varnishncsa.log | grep -c "\(POST\|whateverURLisnoncacheable\)"
and subtract the result from your total of misses, but it's a lot of work to probably produce less accurate results.