<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=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 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.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1242252589;
mso-list-type:hybrid;
mso-list-template-ids:-4434744 1074331665 1074331673 1074331675 1074331663 1074331673 1074331675 1074331663 1074331673 1074331675;}
@list l0:level1
{mso-level-text:"%1\)";
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></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 lang=EN-IN>Hi<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-IN>I am facing an issue where Varnish sends a “If-Modified-Since” header for a cache-miss object.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-IN><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-IN>I will briefly describe the system architecture and the problem for your reference. I have varnish logs saved and can share them as well.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-IN><o:p> </o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-IN><span style='mso-list:Ignore'>1)<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-IN>We have 4 varnish instances running on machine each fetching requests from one backend server. We also have a load balancer in front of these 4 varnishes.<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-IN><span style='mso-list:Ignore'>2)<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-IN>We start Varnish processes using : varnishd -f /etc/varnish/default.vcl -s malloc,2G -T 127.0.0.1:2001 -a 0.0.0.0:8081 -n v1 <o:p></o:p></span></p><p class=MsoNormal style='text-indent:.5in'><span lang=EN-IN>(similarly for v2, v3 and v4). This should make sure that the caches are in memory and exclusive to each varnish instance.<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-IN><span style='mso-list:Ignore'>3)<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-IN>We get 200 OK for a URL, and it’s there on delivered from the varnish cache; suddenly we get a 304 Not modified in one of the clients and that messes up our playback (this is usually when varnish is under load)<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-IN><span style='mso-list:Ignore'>4)<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-IN>On analysis, I figured out that If-Modified-Since header was received at the server end (I can see the header in the Apache logs), since the object was not modified, server returned a 304.<o:p></o:p></span></p><p class=MsoListParagraph><span lang=EN-IN>But till then the object was available in the varnish cache. Did Varnish try to invalidate it’s cache (as the object ttl was set to 2 seconds). If it did so, shouldn’t it keep the object in cache if the server returns a 304?<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-IN><span style='mso-list:Ignore'>5)<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-IN>I don’t see client adding this header<o:p></o:p></span></p><p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-IN><span style='mso-list:Ignore'>6)<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-IN>If I do varnishlog –b, I see a request for this URL from varnish(say v1) to backend and also this was a cache miss. <o:p></o:p></span></p><p class=MsoListParagraph><span lang=EN-IN>My doubt here is, how does Varnish add If-Modified-Since header if it was a cache miss?<o:p></o:p></span></p><p class=MsoListParagraph><span lang=EN-IN><o:p> </o:p></span></p><p class=MsoNormal>Thanks<o:p></o:p></p><p class=MsoNormal>Karishma<o:p></o:p></p></div></body></html>