Determining a HIT or a MISS in Varnish 4 VCL
Umesh Telang
Umesh.Telang at bbc.co.uk
Wed Apr 8 10:50:30 CEST 2015
Thanks Raymond.
If we don't hear any views to the contrary from Varnish themselves, we'll go with the standard approach of using obj.hits
Regards,
Umesh
From: "<Jennings III>", Raymond <raymond.jennings at nytimes.com<mailto:raymond.jennings at nytimes.com>>
Date: Thursday, 2 April 2015 13:38
To: Umesh Telang <Umesh.Telang at bbc.co.uk<mailto:Umesh.Telang at bbc.co.uk>>
Cc: "varnish-misc at varnish-cache.org<mailto:varnish-misc at varnish-cache.org>" <varnish-misc at varnish-cache.org<mailto:varnish-misc at varnish-cache.org>>
Subject: Re: Determining a HIT or a MISS in Varnish 4 VCL
I think that's the way - exactly as you have in vcl_deliver. I've always used that in V3 and now in V4 as well.
I'm suspect of that page telling you to not use obj in vcl_deliver but use that header value instead.
Raymond Jennings III
nytimes.com<http://nytimes.com/>
Office: 212.556.7786<tel:212-556-7786>
iPhone: 914.330.5074<tel:914-330-5074>
E-mail: Raymond.Jennings at nytimes.com<mailto:Raymond.Jennings at nytimes.com>
FaceTime: Raymond.Jennings at nytimes.com<mailto:Raymond.Jennings at nytimes.com>
On Thu, Apr 2, 2015 at 8:28 AM, Umesh Telang <Umesh.Telang at bbc.co.uk<mailto:Umesh.Telang at bbc.co.uk>> wrote:
Hello,
It's unclear if the way to detect whether a particular response was the result of a cache hit or miss in VCL, has changed from Varnish 3 to Varnish 4.
At this page (not an official Varnish page...), it suggests using the value of resp.http.X-Varnish (whether it has a single or multiple values) to determine this:
http://foshttpcache.readthedocs.org/en/latest/varnish-configuration.html#
Alternatively I've also seen suggestions for continuing to use obj.hits in vcl_deliver. e.g. :
sub vcl_deliver {
if (obj.hits > 0) { # Add debug header to see if it's a HIT/MISS and the number of hits, disable when not needed
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
}
We've observed that the value of %{Varnish:handling}x in the varnish ncsa log has been accurate in reporting HITs vs MISSes. Could we use a VCL equivalent of this in vcl_deliver to determine whether a particular response is the result of a HIT or a MISS?
Any advice on the recommended way in VCL to determine whether a response is the result of a HIT or MISS would be greatly appreciated!
Thanks,
Umesh
_______________________________________________
varnish-misc mailing list
varnish-misc at varnish-cache.org<mailto:varnish-misc at varnish-cache.org>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20150408/861fae02/attachment.html>
More information about the varnish-misc
mailing list