<div dir="ltr">Can you provide the varnishlog for a request which isnt getting cached?</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">--<br>Reza Naghibi<br>Varnish Software</div></div></div>
<br><div class="gmail_quote">On Thu, Jul 20, 2017 at 2:03 PM, Girouard, Yanick <span dir="ltr"><<a href="mailto:Yanick.Girouard@stm.info" target="_blank">Yanick.Girouard@stm.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="FR-CA" link="blue" vlink="purple">
<div class="m_5142563769182574498WordSection1">
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Hi Reza,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Yes we are. Here's the default we apply. Those two subs are called in order in vcl_backend_response:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">/* REMOVE CACHE-CONTROL AND SURROGATE-CONTROL FROM BACKEND *<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">******************************<wbr>*****************************/<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">sub stm_backend_resp_unset_cache_<wbr>control_headers {<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">                unset beresp.http.Surrogate-Control;<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">                unset beresp.http.Cache-Control;<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">                unset beresp.http.Expires;<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">}<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">/* DEFAULT ALL TO: TTL 30MIN + GRACE 15MIN *<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">******************************<wbr>*************/<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">sub stm_backend_resp_expiration_<wbr>default {<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">                set beresp.ttl = 30m;<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">                set beresp.grace = 15m;<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">}<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">That doesn't seem to have any impact when the backend responds with a Cache-Control: max-age=0 header.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Any idea?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-CA"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span lang="FR" style="font-size:11.0pt;font-family:"Calibri",sans-serif">De :</span></b><span lang="FR" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Reza Naghibi [mailto:<a href="mailto:reza@varnish-software.com" target="_blank">reza@varnish-software.<wbr>com</a>]
<br>
<b>Envoyé :</b> jeudi 20 juillet 2017 13:58<br>
<b>À :</b> Girouard, Yanick <<a href="mailto:Yanick.Girouard@stm.info" target="_blank">Yanick.Girouard@stm.info</a>><br>
<b>Cc :</b> <a href="mailto:varnish-misc@varnish-cache.org" target="_blank">varnish-misc@varnish-cache.org</a><br>
<b>Objet :</b> Re: Varnish and max-age=0<u></u><u></u></span></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">The TTL is calculated before entering vcl_backend_response. So eventhough you unset the Cache-Control header, the value of TTL will be calculated based on it. Are you setting a new value for beresp.ttl? You need to do that:<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">sub vcl_backend_response<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">{<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">  unset beresp.http.Cache-Control;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">  set beresp.ttl = 120s;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">}<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">--<br>
Reza Naghibi<br>
Varnish Software<u></u><u></u></p>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <<a href="mailto:Yanick.Girouard@stm.info" target="_blank">Yanick.Girouard@stm.info</a>> wrote:<u></u><u></u></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-CA">We use Varnish to cache for multiple backends and need Varnish to
<b>always</b> control what is cached despite what backends could respond. In other words, even if a backend sets Cache-Control headers to never cache its pages, we still want Varnish to cache them based on defined rules (i.e. certain URL patterns or hosts have
 different TTLs).</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-CA"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-CA">We have recently realized that one of our backend always set the following header:
<b>Cache-Control: max-age=0, private, must-revalidate</b></span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-CA"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-CA">Our VCL unsets the Cache-Control header in vcl_backend_response and sets its own before delivering. By unsetting the Cache-Control header in vcl_backend_response
 I would expect Varnish to ignore the max-age=0 value and still cache the page as per our other rules, but it seems that the second it sees max-age=<b>0
</b>in the response header, that it makrs the object as not cacheable.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-CA"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-CA">Other than by changing the backend's response to never set max-age=0, is there a way to force Varnish to cach pages even if it returned max-age=0?</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-CA"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-CA">Is this even by design or is it a bug?</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-CA"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-CA">Thanks,
</span><u></u><u></u></p>
<p class="MsoNormal"><b><span lang="EN-CA" style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#4f5150">Yanick Girouard</span></b><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-CA"> </span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><br>
______________________________<wbr>_________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org" target="_blank">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/<wbr>lists/mailman/listinfo/<wbr>varnish-misc</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>

</blockquote></div><br></div>