<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>One additional information is that if I use browser to trigger the refresh </span><a href="http://riverdale.11alive.com/?refreshcache">http://riverdale.11alive.com/?refreshcache</a><span style='color:#1F497D'>, </span><span style='color:#1F497D'>and later use browser to visit <a href="http://riverdale.11alive.com">http://riverdale.11alive.com</a>, the newly refreshed content is always served. <o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>The randomness of serving refreshed content occurs when I use a java program to programmatically trigger the refresh, and later use browser to visit the site. In vcl_hash you can find only req.url, req.http.host, server.ip, X-UA-Family are used for hash. I can guarantee these 4 attributes are exactly same when I trigger the refresh with browser and java program. So the hashed object should be same. Could Varnish 3.x change something and use some additional attributes not defined in vcl_hash to identify hash objects?<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>I tested on Varnish 3.02 + CentOS 6.2 with same VCL, same problem still exists. <o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>While under old Varnish version 2.0.6, hash_always_miss was not available, so I used the following VCL to refresh the cache with the same java program, it always succeed with no issues. <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:24.0pt'><span style='font-size:8.0pt;font-family:"Verdana","sans-serif";color:#333333'>sub vcl_recv { <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;margin-right:.5in;mso-margin-bottom-alt:auto;margin-left:60.0pt'><span style='font-size:8.0pt;font-family:"Verdana","sans-serif";color:#333333'>set req.grace = 5m; if ((req.http.user-agent == "refresh")||(req.url ~ “\?refreshcache”)) { <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;margin-right:1.0in;mso-margin-bottom-alt:auto;margin-left:96.0pt'><span style='font-size:8.0pt;font-family:"Verdana","sans-serif";color:#333333'>set req.grace = 0s; <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;margin-right:.5in;mso-margin-bottom-alt:auto;margin-left:60.0pt'><span style='font-size:8.0pt;font-family:"Verdana","sans-serif";color:#333333'>} <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:24.0pt'><span style='font-size:8.0pt;font-family:"Verdana","sans-serif";color:#333333'>} <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:24.0pt'><span style='font-size:8.0pt;font-family:"Verdana","sans-serif";color:#333333'>sub vcl_hit { <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;margin-right:.5in;mso-margin-bottom-alt:auto;margin-left:60.0pt'><span style='font-size:8.0pt;font-family:"Verdana","sans-serif";color:#333333'>if (((req.http.user-agent == "refresh")||(req.url ~ “\?refreshcache”)) && req.restarts == 0) { <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;margin-right:1.0in;mso-margin-bottom-alt:auto;margin-left:96.0pt'><span style='font-size:8.0pt;font-family:"Verdana","sans-serif";color:#333333'>set obj.ttl = 0s; restart; <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;margin-right:.5in;mso-margin-bottom-alt:auto;margin-left:60.0pt'><span style='font-size:8.0pt;font-family:"Verdana","sans-serif";color:#333333'>} <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:24.0pt'><span style='font-size:8.0pt;font-family:"Verdana","sans-serif";color:#333333'>} <o:p></o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> varnish-misc-bounces@varnish-cache.org [mailto:varnish-misc-bounces@varnish-cache.org] <b>On Behalf Of </b>Henry Qian<br><b>Sent:</b> Thursday, September 06, 2012 5:13 PM<br><b>To:</b> varnish-misc@varnish-cache.org<br><b>Subject:</b> req.hash_always_miss doesn't work sometimes<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Environment is Varnish 3.03 + CentOS 6.2. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I use req.hash_always_miss=true in vcl_recv to refresh cached pages. However I found the req.hash_always_miss=true doesn’t always works. Sometimes Varnish serves newly refreshed cache content, sometimes Varnish servers old cache content, even through the varnish log reveals the new cache content has been looked up and correctly delivered. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Here is the VCL. <o:p></o:p></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>sub vcl_recv {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set req.backend=hyperlocal;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> if (req.backend.healthy) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set req.grace = 30s;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> } else {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set req.grace = 24h;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> if ((req.http.user-agent == "refresh") || (req.url ~ "\?refreshcache")) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set req.hash_always_miss = true;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> if (req.restarts == 0) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> if (req.http.x-forwarded-for) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set req.http.X-Forwarded-For =<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> req.http.X-Forwarded-For + ", " + client.ip;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> } else {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set req.http.X-Forwarded-For = client.ip;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> if (req.request != "GET" &&<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> req.request != "HEAD" &&<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> req.request != "PUT" &&<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> req.request != "POST" &&<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> req.request != "TRACE" &&<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> req.request != "OPTIONS" &&<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> req.request != "DELETE") {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> /* Non-RFC2616 or CONNECT which is weird. */<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> return (pipe);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> if (req.request != "GET" && req.request != "HEAD") {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> /* We only deal with GET and HEAD by default */<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> return (pass);<o:p></o:p></span></p><p class=MsoNormal style='text-indent:24.0pt;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></p><p class=MsoNormal style='text-indent:24.0pt;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> return (lookup);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># sub vcl_pipe {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># # Note that only the first request to the backend will have<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># # X-Forwarded-For set. If you use X-Forwarded-For and want to<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># # have it set for all requests, make sure to have:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># # set bereq.http.connection = "close";<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># # here. It is not set by default as it might break some broken web<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># # applications, like IIS with NTLM authentication.<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># return (pipe);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># sub vcl_pass {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># return (pass);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># }<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>sub vcl_hash {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> hash_data(req.url);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> if (req.http.host) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> hash_data(req.http.host);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> } else {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> hash_data(server.ip);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> # Add something to differential mobile, tablet, desktop visit.<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> if (req.http.X-UA-Family) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> hash_data(req.http.X-UA-Family);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> return (hash);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>#sub vcl_hit {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># return (deliver);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>#}<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># sub vcl_miss {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># return (fetch);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'># }<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>sub vcl_fetch {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> # Grace to allow varnish to serve content if backend is lagged<o:p></o:p></span></p><p class=MsoNormal style='text-indent:24.0pt;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>set beresp.grace = 24h;<o:p></o:p></span></p><p class=MsoNormal style='text-indent:24.0pt;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-indent:24.0pt;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>if (req.url == "/") {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set beresp.ttl = 720m; // 12 hours<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> } else {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set beresp.ttl = 14400m; // 10 days<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-indent:24.0pt;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> if (req.http.Cookie ~ "(VARNISH|DRUPAL_UID=[^-])") {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set beresp.http.cache-control = "no-cache";<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set beresp.http.X-Cacheable = "NO";<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set beresp.http.ETag = "ADMIN";<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> } else {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set beresp.http.X-Cacheable = "YES";<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> if (beresp.ttl <= 0s ||<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> beresp.http.Set-Cookie ||<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> beresp.http.Vary == "*") {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> /*<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> * Mark as "Hit-For-Pass" for the next 2 minutes<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> */<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set beresp.ttl = 120 s;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> return (hit_for_pass);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-indent:24.0pt;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> return (deliver);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>sub vcl_deliver {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set resp.http.age = "0";<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> #add cache hit data<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> if (obj.hits > 0) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> #if hit add hit count<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set resp.http.X-Cache = "HIT";<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set resp.http.X-Cache-Hits = obj.hits;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> } else {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> set resp.http.X-Cache = "MISS";<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> return (deliver);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p>The below Varnishlog reveals the content of <a href="http://riverdale.11alive.com/">http://riverdale.11alive.com/</a> has been refreshed, triggered by a special request <a href="http://riverdale.11alive.com/?refreshcache">http://riverdale.11alive.com/?refreshcache</a>. The log reveals the refresh is successful.<o:p></o:p></p><p> 60 SessionOpen c 127.0.0.1 56116 :6081<br> 60 ReqStart c 127.0.0.1 56116 1570899703<br> 60 RxRequest c GET<br> 60 RxURL c /?refreshcache<br> 60 RxProtocol c HTTP/1.0<br> 60 RxHeader c Host: riverdale.11alive.com<br> 60 RxHeader c X-Real-IP: 10.112.0.221<br> 60 RxHeader c X-Forwarded-For: 10.113.0.134, 10.112.0.221<br> 60 RxHeader c X-Client-Verify: SUCCESS<br> 60 RxHeader c X-UA-Family: desktop<br> 60 RxHeader c Connection: close<br> 60 RxHeader c User-Agent: Java/1.6.0_20<br> 60 RxHeader c Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2<br> 60 VCL_call c recv lookup<br> 60 VCL_call c hash<br> 60 Hash c /<br> 60 Hash c riverdale.11alive.com<br> 60 Hash c desktop<br> 60 VCL_return c hash<br> 60 VCL_call c miss fetch<br> 60 Backend c 61 hyperlocal hyperlocal<br> 60 TTL c 1570899703 RFC 120 -1 -1 1346968996 0 1346968992 0 0<br> 60 VCL_call c fetch<br> 60 TTL c 1570899703 VCL 123 86400 -1 1346968993 -3<br> 60 TTL c 1570899703 VCL 43203 86400 -1 1346968993 -3<br> 60 VCL_return c deliver<br> 60 ObjProtocol c HTTP/1.1<br> 60 ObjResponse c OK<br> 60 ObjHeader c Date: Thu, 06 Sep 2012 22:03:12 GMT<br> 60 ObjHeader c Server: Apache/2.2.15 (CentOS)<br> 60 ObjHeader c Vary: User-Agent,Accept-Encoding<br> 60 ObjHeader c X-Powered-By: PHP/5.3.3<br> 60 ObjHeader c X-Drupal-Cache: MISS<br> 60 ObjHeader c Last-Modified: Thu, 06 Sep 2012 22:03:12 +0000<br> 60 ObjHeader c Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0<br> 60 ObjHeader c ETag: "1346968992"<br> 60 ObjHeader c Content-Encoding: gzip<br> 60 ObjHeader c Content-Type: text/html; charset=utf-8<br> 60 ObjHeader c X-Cacheable: YES<br> 60 Gzip c u F - 27026 155024 80 80 216139<br> 60 VCL_call c deliver deliver<br> 60 TxProtocol c HTTP/1.1<br> 60 TxStatus c 200<br> 60 TxResponse c OK<br> 60 TxHeader c Server: Apache/2.2.15 (CentOS)<br> 60 TxHeader c Vary: User-Agent,Accept-Encoding<br> 60 TxHeader c X-Powered-By: PHP/5.3.3<br> 60 TxHeader c X-Drupal-Cache: MISS<br> 60 TxHeader c Last-Modified: Thu, 06 Sep 2012 22:03:12 +0000<br> 60 TxHeader c Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0<br> 60 TxHeader c ETag: "1346968992"<br> 60 TxHeader c Content-Type: text/html; charset=utf-8<br> 60 TxHeader c X-Cacheable: YES<br> 60 TxHeader c Date: Thu, 06 Sep 2012 22:03:16 GMT<br> 60 TxHeader c X-Varnish: 1570899703<br> 60 TxHeader c Via: 1.1 varnish<br> 60 TxHeader c Connection: close<br> 60 TxHeader c age: 0<br> 60 TxHeader c X-Cache: MISS<br> 60 Gzip c U D - 27026 155024 80 80 216139<br> 60 Length c 155024<br> 60 ReqEnd c 1570899703 1346968992.932512045 1346968996.214715719 0.000031471 3.280443430 0.001760244<o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'></span>However later when I visited the <a href="http://riverdale.11alive.com/">http://riverdale.11alive.com/</a>, I got old content with the following header information. From the header information below, you can find the content is last modified on Thu, 06 Sep 2012 21:31:16 +0000, instead of the Last-Modified: Thu, 06 Sep 2012 22:03:12 +0000 as indicated in the varnish log.<o:p></o:p></p><p>Response Headersview source<br>Age 0<br>Cache-Control no-cache, must-revalidate, post-check=0, pre-check=0<br>Connection close<br>Content-Encoding gzip<br>Content-Type text/html; charset=utf-8<br>Date Thu, 06 Sep 2012 22:10:57 GMT<br>Etag "1346967076"<br>Last-Modified Thu, 06 Sep 2012 21:31:16 +0000<br>Server nginx/1.0.14<br>Transfer-Encoding chunked<br>Vary Accept-Encoding, Accept-Encoding<br>Via 1.1 varnish<br>X-Cache HIT<br>X-Cache-Hits 4<br>X-Cacheable YES<br>X-Drupal-Cache MISS<br>X-Powered-By PHP/5.2.10<br>X-Varnish 1570906726 1570869110<o:p></o:p></p><p>Request Headersview source<br>Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br>Accept-Encoding gzip, deflate<br>Accept-Language en-us,en;q=0.5<br>Cache-Control no-cache<br>Connection keep-alive<br>Cookie s_cc=true; s_sq=%5B%5BB%5D%5D; hl-email-avoid=true; __utma=196336364.508874118.1346959523.1346959523.1346969008.2; __utmc=196336364; __utmz=196336364.1346959523.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); SiteLifeHost=l3vm105l3pluckcom; anonId=0227849c-521b-4054-a1cc-864ad8a54073; __utmb=196336364.34.0.1346969440935; BC_BANDWIDTH=1346969016992X1808<br>Host riverdale.11alive.com<br>Pragma no-cache<br>User-Agent Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0<o:p></o:p></p><p>Did I miss anything or Varnish req.hash_always_miss doesn't work as expected sometimes and thus is a bug?<o:p></o:p></p><p>Here I also post a good one, which is actually the request just before the bad one. You can tell it by checking the ObjHeader ETag. The good one is “1346968991”, while the bad one is “1346968992”. Varnish as expected miss fetched the content from backend. <o:p></o:p></p><p> 79 SessionOpen c 127.0.0.1 55822 :6081<o:p></o:p></p><p> 79 ReqStart c 127.0.0.1 55822 1570899684<o:p></o:p></p><p> 79 RxRequest c GET<o:p></o:p></p><p> 79 RxURL c /?refreshcache<o:p></o:p></p><p> 79 RxProtocol c HTTP/1.0<o:p></o:p></p><p> 79 RxHeader c Host: northslocounty.kcoy.com<o:p></o:p></p><p> 79 RxHeader c X-Real-IP: 10.112.0.221<o:p></o:p></p><p> 79 RxHeader c X-Forwarded-For: 10.113.0.134, 10.112.0.221<o:p></o:p></p><p> 79 RxHeader c X-Client-Verify: SUCCESS<o:p></o:p></p><p> 79 RxHeader c X-UA-Family: desktop<o:p></o:p></p><p> 79 RxHeader c Connection: close<o:p></o:p></p><p> 79 RxHeader c User-Agent: Java/1.6.0_20<o:p></o:p></p><p> 79 RxHeader c Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2<o:p></o:p></p><p> 79 VCL_call c recv lookup<o:p></o:p></p><p> 79 VCL_call c hash<o:p></o:p></p><p> 79 Hash c /<o:p></o:p></p><p> 79 Hash c northslocounty.kcoy.com<o:p></o:p></p><p> 79 Hash c desktop<o:p></o:p></p><p> 79 VCL_return c hash<o:p></o:p></p><p> 79 VCL_call c miss fetch<o:p></o:p></p><p> 79 Backend c 80 hyperlocal hyperlocal<o:p></o:p></p><p> 79 TTL c 1570899684 RFC 120 -1 -1 1346968993 0 1346968991 0 0<o:p></o:p></p><p> 79 VCL_call c fetch<o:p></o:p></p><p> 79 TTL c 1570899684 VCL 122 86400 -1 1346968991 -2<o:p></o:p></p><p> 79 TTL c 1570899684 VCL 43202 86400 -1 1346968991 -2<o:p></o:p></p><p> 79 VCL_return c deliver<o:p></o:p></p><p> 79 ObjProtocol c HTTP/1.1<o:p></o:p></p><p> 79 ObjResponse c OK<o:p></o:p></p><p> 79 ObjHeader c Date: Thu, 06 Sep 2012 22:03:11 GMT<o:p></o:p></p><p> 79 ObjHeader c Server: Apache/2.2.3 (CentOS)<o:p></o:p></p><p> 79 ObjHeader c X-Powered-By: PHP/5.2.10<o:p></o:p></p><p> 79 ObjHeader c X-Drupal-Cache: MISS<o:p></o:p></p><p> 79 ObjHeader c Last-Modified: Thu, 06 Sep 2012 22:03:11 +0000<o:p></o:p></p><p> 79 ObjHeader c Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0<o:p></o:p></p><p> 79 ObjHeader c ETag: "1346968991"<o:p></o:p></p><p> 79 ObjHeader c Vary: Accept-Encoding<o:p></o:p></p><p> 79 ObjHeader c Content-Encoding: gzip<o:p></o:p></p><p> 79 ObjHeader c Content-Type: text/html; charset=utf-8<o:p></o:p></p><p> 79 ObjHeader c X-Cacheable: YES<o:p></o:p></p><p> 79 Gzip c u F - 19388 110022 80 80 155035<o:p></o:p></p><p> 79 VCL_call c deliver deliver<o:p></o:p></p><p> 79 TxProtocol c HTTP/1.1<o:p></o:p></p><p> 79 TxStatus c 200<o:p></o:p></p><p> 79 TxResponse c OK<o:p></o:p></p><p> 79 TxHeader c Server: Apache/2.2.3 (CentOS)<o:p></o:p></p><p> 79 TxHeader c X-Powered-By: PHP/5.2.10<o:p></o:p></p><p> 79 TxHeader c X-Drupal-Cache: MISS<o:p></o:p></p><p> 79 TxHeader c Last-Modified: Thu, 06 Sep 2012 22:03:11 +0000<o:p></o:p></p><p> 79 TxHeader c Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0<o:p></o:p></p><p> 79 TxHeader c ETag: "1346968991"<o:p></o:p></p><p> 79 TxHeader c Vary: Accept-Encoding<o:p></o:p></p><p> 79 TxHeader c Content-Type: text/html; charset=utf-8<o:p></o:p></p><p> 79 TxHeader c X-Cacheable: YES<o:p></o:p></p><p> 79 TxHeader c Date: Thu, 06 Sep 2012 22:03:12 GMT<o:p></o:p></p><p> 79 TxHeader c X-Varnish: 1570899684<o:p></o:p></p><p> 79 TxHeader c Via: 1.1 varnish<o:p></o:p></p><p> 79 TxHeader c Connection: close<o:p></o:p></p><p> 79 TxHeader c age: 0<o:p></o:p></p><p> 79 TxHeader c X-Cache: MISS<o:p></o:p></p><p> 79 Gzip c U D - 19388 110022 80 80 155035<o:p></o:p></p><p> 79 Length c 110022<o:p></o:p></p><p> 79 ReqEnd c 1570899684 1346968991.255424976 1346968992.866729498 0.000033379 1.610149622 0.001154900<o:p></o:p></p><p><o:p> </o:p></p><p>And then later when I visit the site, <a href="http://northslocounty.kcoy.com">http://northslocounty.kcoy.com</a>, the latest cache content was served. Please see header information below. <o:p></o:p></p><p>Response Headersview source<o:p></o:p></p><p>Age 0<o:p></o:p></p><p>Cache-Control no-cache, must-revalidate, post-check=0, pre-check=0<o:p></o:p></p><p>Connection close<o:p></o:p></p><p>Content-Encoding gzip<o:p></o:p></p><p>Content-Type text/html; charset=utf-8<o:p></o:p></p><p>Date Thu, 06 Sep 2012 22:05:42 GMT<o:p></o:p></p><p>Etag "1346968991"<o:p></o:p></p><p>Last-Modified Thu, 06 Sep 2012 22:03:11 +0000<o:p></o:p></p><p>Server nginx/1.0.14<o:p></o:p></p><p>Transfer-Encoding chunked<o:p></o:p></p><p>Vary Accept-Encoding, Accept-Encoding<o:p></o:p></p><p>Via 1.1 varnish<o:p></o:p></p><p>X-Cache HIT<o:p></o:p></p><p>X-Cache-Hits 2<o:p></o:p></p><p>X-Cacheable YES<o:p></o:p></p><p>X-Drupal-Cache MISS<o:p></o:p></p><p>X-Powered-By PHP/5.2.10<o:p></o:p></p><p>X-Varnish 1570901954 1570899684<o:p></o:p></p><p><o:p> </o:p></p><p>Request Headersview source<o:p></o:p></p><p>Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<o:p></o:p></p><p>Accept-Encoding gzip, deflate<o:p></o:p></p><p>Accept-Language en-us,en;q=0.5<o:p></o:p></p><p>Connection keep-alive<o:p></o:p></p><p>Cookie hl-email-avoid=true<o:p></o:p></p><p>Host northslocounty.kcoy.com<o:p></o:p></p><p>User-Agent Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0<o:p></o:p></p><p class=MsoNormal>Thanks,<o:p></o:p></p><p class=MsoNormal>-Henry<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>