Determining a HIT or a MISS in Varnish 4 VCL

Jennings III, Raymond raymond.jennings at nytimes.com
Thu Apr 2 14:38:48 CEST 2015


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 <212-556-7786>*

*iPhone: 914.330.5074 <914-330-5074>E-mail: Raymond.Jennings at nytimes.com
<Raymond.Jennings at nytimes.com>FaceTime: Raymond.Jennings at nytimes.com
<Raymond.Jennings at nytimes.com>*

On Thu, Apr 2, 2015 at 8:28 AM, Umesh Telang <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
> 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/20150402/3aa5b9f7/attachment.html>


More information about the varnish-misc mailing list