<div dir="ltr">Common mistake, beresp.uncacheable isn't the opposite of beresp.ttl>0. "uncacheable" tells Varnish that if it gets a HIT for that object, it should convert it to a PASS/MISS (depending on the versions) and avoir request coalescing. In that scenario too, the ttl is the time the object will live in cache. ie. how long do you retain the memory that it's not cacheable.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>-- <br></div>Guillaume Quintard<br></div></div></div>
<br><div class="gmail_quote">On Fri, Jul 21, 2017 at 12:09 AM, 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">That's a good thought, but what would really be the impact of this setting if I've already set the ttl to a positive value after stripping all headers that would make Varnish consider the object as being uncacheable to begin with? Is there a case where it would be required?<br>
<br>
<br>
______________________________<wbr>__<br>
De : Andrei <<a href="mailto:lagged@gmail.com">lagged@gmail.com</a>><br>
Envoyé : 20 juillet 2017 15:22<br>
À : Girouard, Yanick<br>
Cc : Reza Naghibi; <a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
<span class="">Objet : Re: Varnish and max-age=0<br>
<br>
</span><span class="">Just a thought, if you're going to force an otherwise uncacheable request to be cached, you should probably: set beresp.uncacheable = false;<br>
<br>
<br>
<br>
</span><span class="">On Thu, Jul 20, 2017 at 9:03 PM, Girouard, Yanick <<a href="mailto:Yanick.Girouard@stm.info">Yanick.Girouard@stm.info</a><<wbr>mailto:<a href="mailto:Yanick.Girouard@stm.info">Yanick.Girouard@stm.<wbr>info</a>>> wrote:<br>
Hi Reza,<br>
<br>
Yes we are. Here's the default we apply. Those two subs are called in order in vcl_backend_response:<br>
<br>
/* REMOVE CACHE-CONTROL AND SURROGATE-CONTROL FROM BACKEND *<br>
******************************<wbr>*****************************/<br>
sub stm_backend_resp_unset_cache_<wbr>control_headers {<br>
unset beresp.http.Surrogate-Control;<br>
unset beresp.http.Cache-Control;<br>
unset beresp.http.Expires;<br>
}<br>
<br>
/* DEFAULT ALL TO: TTL 30MIN + GRACE 15MIN *<br>
******************************<wbr>*************/<br>
sub stm_backend_resp_expiration_<wbr>default {<br>
set beresp.ttl = 30m;<br>
set beresp.grace = 15m;<br>
}<br>
<br>
That doesn't seem to have any impact when the backend responds with a Cache-Control: max-age=0 header.<br>
<br>
Any idea?<br>
<br>
<br>
</span>De : Reza Naghibi [mailto:<a href="mailto:reza@varnish-software.com">reza@varnish-software.<wbr>com</a><mailto:<a href="mailto:reza@varnish-software.com">reza@varnish-<wbr>software.com</a>>]<br>
<span class="">Envoyé : jeudi 20 juillet 2017 13:58<br>
</span>À : Girouard, Yanick <<a href="mailto:Yanick.Girouard@stm.info">Yanick.Girouard@stm.info</a><<wbr>mailto:<a href="mailto:Yanick.Girouard@stm.info">Yanick.Girouard@stm.<wbr>info</a>>><br>
Cc : <a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><wbr><mailto:<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-<wbr>cache.org</a>><br>
<span class="">Objet : Re: Varnish and max-age=0<br>
<br>
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:<br>
<br>
sub vcl_backend_response<br>
{<br>
unset beresp.http.Cache-Control;<br>
set beresp.ttl = 120s;<br>
}<br>
<br>
--<br>
Reza Naghibi<br>
Varnish Software<br>
<br>
</span><span class="">On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <<a href="mailto:Yanick.Girouard@stm.info">Yanick.Girouard@stm.info</a><<wbr>mailto:<a href="mailto:Yanick.Girouard@stm.info">Yanick.Girouard@stm.<wbr>info</a>>> wrote:<br>
Hi,<br>
<br>
We use Varnish to cache for multiple backends and need Varnish to always 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).<br>
<br>
We have recently realized that one of our backend always set the following header: Cache-Control: max-age=0, private, must-revalidate<br>
<br>
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=0 in the response header, that it makrs the object as not cacheable.<br>
<br>
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?<br>
<br>
Is this even by design or is it a bug?<br>
<br>
Thanks,<br>
Yanick Girouard<br>
<br>
<br>
______________________________<wbr>_________________<br>
varnish-misc mailing list<br>
</span><a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><wbr><mailto:<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-<wbr>cache.org</a>><br>
<span class=""><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>
<br>
<br>
______________________________<wbr>_________________<br>
varnish-misc mailing list<br>
</span><a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><wbr><mailto:<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-<wbr>cache.org</a>><br>
<div class="HOEnZb"><div class="h5"><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>
<br>
<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>
</div></div></blockquote></div><br></div>