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
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to