<div dir="ltr">Hi,<div><br></div><div>Yes it's possible. I did something similar on my configuration :</div><div><br></div><div>I use the header req.http.X-Pass to set the reason why I get a MISS / PASS : </div><div><b><br></b></div><div><b>Exemple</b> </div><div>sub vcl_recv {<br></div><div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>if (req.url ~ "\?s="</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span> || req.url ~ "/feed"</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span> || req.url ~ "/mu-.*"</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span> || req.url ~ "/wp-(login|admin)"</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span> || req.url ~ "/(cart|my-account|checkout|addons|/?add-to-cart=)") {</div><div><br></div><div> set req.http.X-Pass = "Wordpress Urls";</div><div> return (pass);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>}</div></div><div>}<br><br>In the subroutine MISS, used when your object is not in cache I had the header too.</div><div>sub vcl_miss {<br></div><div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>set req.http.X-Pass = "Not-in-cache";<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>return (fetch);</div><div>}</div></div><div><br></div><div><br></div><div>I change the condition in the vcl_deliver to display the reason of the MISS (and you could differenciate if it was a real MISS or if it was a PASS), and use this condition (<b>obj.uncacheable</b>) that allow me to know if the object has mark as Hit-For-Pass <br></div><div><br></div><div><div>sub vcl_deliver {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>if (obj.hits > 0) {<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>set resp.http.X-Cache = "HIT";</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>} else if (obj.uncacheable && req.http.X-Pass ~ "Not-in-Cache") {<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>set resp.http.X-Cache = "MISS : Hit-For-Pass";</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>} else {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span> set resp.http.X-Cache = "MISS : " + req.http.X-Pass;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>}</div></div><div>}<br></div><div><br></div><div><br></div><div><br></div><div>So you could had a header in the vcl_pass and test it in order you display PASS instead of MISS in the vcl_deliver</div><div><br></div><div>Nicolas</div><div><br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div><font color="#3366ff"></font> </div><div><b><font color="#3366ff"></font></b> </div><div><b><font color="#3366ff">Nicolas Delmas</font></b></div><div><a href="mailto:colas.delmas@gmail.com" target="_blank">http://tutoandco.colas-delmas.fr/</a></div></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div></div></div></div></div>
<br><div class="gmail_quote">2017-05-18 8:56 GMT+02:00 sreeranj s <span dir="ltr"><<a href="mailto:sreeranj4droid@gmail.com" target="_blank">sreeranj4droid@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi All,<div><br></div><div><br></div><div>Following is added in vcl-deliver section to identify if the content is served from cache or from backend. Similarly is there an option that we can identify if the request was a PASS </div><div><br></div><div>==============================<wbr>============</div><div><pre class="m_-3569407954574615335gmail-c">sub vcl_deliver <span style="color:rgb(0,153,0)">{</span>
<span style="color:rgb(51,153,51)"># Sometimes it's nice to see when content has been served from the cache. </span>
<span style="color:rgb(177,177,0)">if</span> <span style="color:rgb(0,153,0)">(</span>obj.<span style="color:rgb(32,32,32)">hits</span> <span style="color:rgb(51,153,51)">></span> <span style="color:rgb(0,0,221)">0</span><span style="color:rgb(0,153,0)">)</span> <span style="color:rgb(0,153,0)">{</span>
<span style="color:rgb(51,153,51)"># If the object came from the cache, set an HTTP header to say so</span>
set resp.<span style="color:rgb(32,32,32)">http</span>.<span style="color:rgb(32,32,32)">X</span><span style="color:rgb(51,153,51)">-</span>Cache <span style="color:rgb(51,153,51)">=</span> <span style="color:rgb(255,0,0)">"HIT"</span><span style="color:rgb(51,153,51)">;</span>
<span style="color:rgb(0,153,0)">}</span> <span style="color:rgb(177,177,0)">else</span> <span style="color:rgb(0,153,0)">{</span>
set resp.<span style="color:rgb(32,32,32)">http</span>.<span style="color:rgb(32,32,32)">X</span><span style="color:rgb(51,153,51)">-</span>Cache <span style="color:rgb(51,153,51)">=</span> <span style="color:rgb(255,0,0)">"MISS"</span><span style="color:rgb(51,153,51)">;</span>
<span style="color:rgb(0,153,0)">}</span>
<span style="color:rgb(51,153,51)"># For security and asthetic reasons, remove some HTTP headers before final delivery...</span>
<span style="color:rgb(0,0,102)">remove</span> resp.<span style="color:rgb(32,32,32)">http</span>.<span style="color:rgb(32,32,32)">Server</span><span style="color:rgb(51,153,51)">;</span>
<span style="color:rgb(0,0,102)">remove</span> resp.<span style="color:rgb(32,32,32)">http</span>.<span style="color:rgb(32,32,32)">X</span><span style="color:rgb(51,153,51)">-</span>Powered<span style="color:rgb(51,153,51)">-</span>By<span style="color:rgb(51,153,51)">;</span>
<span style="color:rgb(0,0,102)">remove</span> resp.<span style="color:rgb(32,32,32)">http</span>.<span style="color:rgb(32,32,32)">Via</span><span style="color:rgb(51,153,51)">;</span>
<span style="color:rgb(0,0,102)">remove</span> resp.<span style="color:rgb(32,32,32)">http</span>.<span style="color:rgb(32,32,32)">X</span><span style="color:rgb(51,153,51)">-</span>Varnish<span style="color:rgb(51,153,51)">;</span>
<span style="color:rgb(0,153,0)">}</span></pre><div><br></div><div><br class="m_-3569407954574615335gmail-Apple-interchange-newline">==============================<wbr>============<br></div></div></div>
<br>______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://www.varnish-cache.org/<wbr>lists/mailman/listinfo/<wbr>varnish-misc</a><br></blockquote></div><br></div>