<div dir="ltr">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.<div><br></div><div>I'm suspect of that page telling you to not use obj in vcl_deliver but use that header value instead.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-weight:bold"><span style="white-space:pre-wrap"><u> </u></span></div><div style="color:rgb(0,0,0)"><font face="Helvetica"><span style="font-size:12px">Raymond Jennings III</span></font></div></div><span style="color:rgb(0,0,0);text-align:-webkit-auto;font-family:Helvetica"><font face="Rockwell Extra Bold" style="font-size:19px"><b><a href="http://nytimes.com/" style="color:rgb(17,85,204)" target="_blank">nytimes.com</a></b></font><br></span><div style="color:rgb(0,0,0);font-family:Helvetica"><span style="text-align:-webkit-auto"><span style="font-size:12px;text-align:-webkit-auto"><b><div style="display:inline!important">Office:<span style="font-weight:normal"> <a href="tel:212-556-7786" target="_blank">212.556.7786</a></span></div></b></span><span style="text-align:-webkit-auto"><span style="text-align:-webkit-auto"><b style="font-size:12px;text-align:-webkit-auto"><div>iPhone:<span style="font-weight:normal"> <a href="tel:914-330-5074" target="_blank">914.330.5074</a></span></div><div><b style="font-size:13px">E-mail: </b><a href="mailto:Raymond.Jennings@nytimes.com" style="font-size:13px;font-weight:normal;color:rgb(17,85,204)" target="_blank">Raymond.Jennings@nytimes.com</a><br></div><div>FaceTime:<span style="font-weight:normal"> <a href="mailto:Raymond.Jennings@nytimes.com" style="color:rgb(17,85,204)" target="_blank">Raymond.Jennings@nytimes.com</a></span></div></b></span></span></span></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Apr 2, 2015 at 8:28 AM, Umesh Telang <span dir="ltr"><<a href="mailto:Umesh.Telang@bbc.co.uk" target="_blank">Umesh.Telang@bbc.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;color:rgb(0,0,0)">
<div style="font-size:14px;font-family:Calibri,sans-serif">Hello,</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">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.</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">At this page (not an official Varnish page...), it suggests using the value of <span>resp</span><span>.</span><span>http</span><span>.</span><span>X</span><span>-</span><span>Varnish
(whether it has a single or multiple values) to determine this:</span></div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><span><a href="http://foshttpcache.readthedocs.org/en/latest/varnish-configuration.html" target="_blank">http://foshttpcache.readthedocs.org/en/latest/varnish-configuration.html</a>#</span></div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><span><br>
</span></div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><span>Alternatively I've also seen suggestions for continuing to use obj.hits in vcl_deliver. e.g. :</span></div>
<div><span style="font-size:10px"><font face="Consolas">sub vcl_deliver { </font></span></div>
<div><span style="font-size:10px"><font face="Consolas">
<table>
<tbody>
<tr>
<td><span style="font-size:10px">if (obj.hits > 0) { # Add debug header to see if it's a HIT/MISS and the number of hits, disable when not needed</span></td>
</tr>
<tr>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
</tr>
<tr>
<td><span style="font-size:10px">set resp.http.X-Cache = "HIT";</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td><span style="font-size:10px">} else {</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td><span style="font-size:10px">set resp.http.X-Cache = "MISS";</span></td>
</tr>
<tr>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td><span style="font-size:10px">}</span></td>
</tr>
</tbody>
</table>
</font></span></div>
<div><span style="font-size:10px"><font face="Consolas">}</font></span></div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><span><br>
</span></div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><span>We've observed that the value of %{</span>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?</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">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!</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">Thanks,</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">Umesh</div>
<pre style="font-size:14px;font-family:Calibri,sans-serif"><span></span><span></span></pre>
</div>
<br>_______________________________________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
<a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br></blockquote></div><br></div>