<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; 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 class="n">resp</span><span class="p">.</span><span class="n">http</span><span class="p">.</span><span class="n">X</span><span class="o">-</span><span class="n">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 class="n"><a href="http://foshttpcache.readthedocs.org/en/latest/varnish-configuration.html">http://foshttpcache.readthedocs.org/en/latest/varnish-configuration.html</a>#</span></div>
<div style="font-size: 14px; font-family: Calibri, sans-serif;"><span class="n"><br>
</span></div>
<div style="font-size: 14px; font-family: Calibri, sans-serif;"><span class="n">Alternatively I've also seen suggestions for continuing to use obj.hits in vcl_deliver. e.g. :</span></div>
<div><span class="n" style="font-size: 10px;"><font face="Consolas">sub vcl_deliver { </font></span></div>
<div><span class="n" style="font-size: 10px;"><font face="Consolas">
<table class="highlight tab-size-8 js-file-line-container">
<tbody>
<tr>
<td id="LC397" class="blob-code js-file-line"><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 class="highlight tab-size-8 js-file-line-container">
<tbody>
<tr>
</tr>
<tr>
<td id="LC398" class="blob-code js-file-line"><span style="font-size: 10px;">set resp.http.X-Cache = "HIT";</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC399" class="blob-code js-file-line"><span style="font-size: 10px;">} else {</span></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td id="LC400" class="blob-code js-file-line"><span style="font-size: 10px;">set resp.http.X-Cache = "MISS";</span></td>
</tr>
<tr>
</tr>
</tbody>
</table>
<table class="highlight tab-size-8 js-file-line-container">
<tbody>
<tr>
<td id="LC401" class="blob-code js-file-line"><span style="font-size: 10px;">}</span></td>
</tr>
</tbody>
</table>
</font></span></div>
<div><span class="n" style="font-size: 10px;"><font face="Consolas">}</font></span></div>
<div style="font-size: 14px; font-family: Calibri, sans-serif;"><span class="n"><br>
</span></div>
<div style="font-size: 14px; font-family: Calibri, sans-serif;"><span class="n">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 class="p"></span><span class="o"></span></pre>
</body>
</html>