Mailing List Archive

Varnish and max-age=0
Hi,

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).

We have recently realized that one of our backend always set the following header: Cache-Control: max-age=0, private, must-revalidate

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.

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?

Is this even by design or is it a bug?

Thanks,
Yanick Girouard
Re: Varnish and max-age=0 [ In reply to ]
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:

sub vcl_backend_response
{
unset beresp.http.Cache-Control;
set beresp.ttl = 120s;
}

--
Reza Naghibi
Varnish Software

On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <Yanick.Girouard@stm.info>
wrote:

> Hi,
>
>
>
> 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).
>
>
>
> We have recently realized that one of our backend always set the following
> header: *Cache-Control: max-age=0, private, must-revalidate*
>
>
>
> 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.
>
>
>
> 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?
>
>
>
> Is this even by design or is it a bug?
>
>
>
> Thanks,
>
> *Yanick Girouard*
>
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
RE: Varnish and max-age=0 [ In reply to ]
Hi Reza,

Yes we are. Here's the default we apply. Those two subs are called in order in vcl_backend_response:

/* REMOVE CACHE-CONTROL AND SURROGATE-CONTROL FROM BACKEND *
***********************************************************/
sub stm_backend_resp_unset_cache_control_headers {
unset beresp.http.Surrogate-Control;
unset beresp.http.Cache-Control;
unset beresp.http.Expires;
}

/* DEFAULT ALL TO: TTL 30MIN + GRACE 15MIN *
*******************************************/
sub stm_backend_resp_expiration_default {
set beresp.ttl = 30m;
set beresp.grace = 15m;
}

That doesn't seem to have any impact when the backend responds with a Cache-Control: max-age=0 header.

Any idea?


De : Reza Naghibi [mailto:reza@varnish-software.com]
Envoyé : jeudi 20 juillet 2017 13:58
À : Girouard, Yanick <Yanick.Girouard@stm.info>
Cc : varnish-misc@varnish-cache.org
Objet : Re: Varnish and max-age=0

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:

sub vcl_backend_response
{
unset beresp.http.Cache-Control;
set beresp.ttl = 120s;
}

--
Reza Naghibi
Varnish Software

On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
Hi,

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).

We have recently realized that one of our backend always set the following header: Cache-Control: max-age=0, private, must-revalidate

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.

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?

Is this even by design or is it a bug?

Thanks,
Yanick Girouard


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Varnish and max-age=0 [ In reply to ]
Can you provide the varnishlog for a request which isnt getting cached?

--
Reza Naghibi
Varnish Software

On Thu, Jul 20, 2017 at 2:03 PM, Girouard, Yanick <Yanick.Girouard@stm.info>
wrote:

> Hi Reza,
>
>
>
> Yes we are. Here's the default we apply. Those two subs are called in
> order in vcl_backend_response:
>
>
>
> /* REMOVE CACHE-CONTROL AND SURROGATE-CONTROL FROM BACKEND *
>
> ***********************************************************/
>
> sub stm_backend_resp_unset_cache_control_headers {
>
> unset beresp.http.Surrogate-Control;
>
> unset beresp.http.Cache-Control;
>
> unset beresp.http.Expires;
>
> }
>
>
>
> /* DEFAULT ALL TO: TTL 30MIN + GRACE 15MIN *
>
> *******************************************/
>
> sub stm_backend_resp_expiration_default {
>
> set beresp.ttl = 30m;
>
> set beresp.grace = 15m;
>
> }
>
>
>
> That doesn't seem to have any impact when the backend responds with a
> Cache-Control: max-age=0 header.
>
>
>
> Any idea?
>
>
>
>
>
> *De :* Reza Naghibi [mailto:reza@varnish-software.com]
> *Envoyé :* jeudi 20 juillet 2017 13:58
> *À :* Girouard, Yanick <Yanick.Girouard@stm.info>
> *Cc :* varnish-misc@varnish-cache.org
> *Objet :* Re: Varnish and max-age=0
>
>
>
> 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:
>
>
>
> sub vcl_backend_response
>
> {
>
> unset beresp.http.Cache-Control;
>
> set beresp.ttl = 120s;
>
> }
>
>
> --
> Reza Naghibi
> Varnish Software
>
>
>
> On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <
> Yanick.Girouard@stm.info> wrote:
>
> Hi,
>
>
>
> 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).
>
>
>
> We have recently realized that one of our backend always set the following
> header: *Cache-Control: max-age=0, private, must-revalidate*
>
>
>
> 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.
>
>
>
> 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?
>
>
>
> Is this even by design or is it a bug?
>
>
>
> Thanks,
>
> *Yanick Girouard*
>
>
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
>
RE: Varnish and max-age=0 [ In reply to ]
Interesting… Following your response, I've tested setting beresp.ttl in a simplified version of our VCL and it's caching the request even with max-age=0… So that means something else is causing this in my VCL. I will try to debug it further and see if I can find it.

Thanks!

De : Reza Naghibi [mailto:reza@varnish-software.com]
Envoyé : jeudi 20 juillet 2017 14:06
À : Girouard, Yanick <Yanick.Girouard@stm.info>
Cc : varnish-misc@varnish-cache.org
Objet : Re: Varnish and max-age=0

Can you provide the varnishlog for a request which isnt getting cached?

--
Reza Naghibi
Varnish Software

On Thu, Jul 20, 2017 at 2:03 PM, Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
Hi Reza,

Yes we are. Here's the default we apply. Those two subs are called in order in vcl_backend_response:

/* REMOVE CACHE-CONTROL AND SURROGATE-CONTROL FROM BACKEND *
***********************************************************/
sub stm_backend_resp_unset_cache_control_headers {
unset beresp.http.Surrogate-Control;
unset beresp.http.Cache-Control;
unset beresp.http.Expires;
}

/* DEFAULT ALL TO: TTL 30MIN + GRACE 15MIN *
*******************************************/
sub stm_backend_resp_expiration_default {
set beresp.ttl = 30m;
set beresp.grace = 15m;
}

That doesn't seem to have any impact when the backend responds with a Cache-Control: max-age=0 header.

Any idea?


De : Reza Naghibi [mailto:reza@varnish-software.com<mailto:reza@varnish-software.com>]
Envoyé : jeudi 20 juillet 2017 13:58
À : Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>>
Cc : varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
Objet : Re: Varnish and max-age=0

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:

sub vcl_backend_response
{
unset beresp.http.Cache-Control;
set beresp.ttl = 120s;
}

--
Reza Naghibi
Varnish Software

On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
Hi,

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).

We have recently realized that one of our backend always set the following header: Cache-Control: max-age=0, private, must-revalidate

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.

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?

Is this even by design or is it a bug?

Thanks,
Yanick Girouard


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Varnish and max-age=0 [ In reply to ]
Yanick,

You may just need to set beresp.ttl to a value and Varnish should obey it. And possibly unset cookies. For example-

sub vcl_backend_response {
if (bereq.url ~ "somepage\.php" && beresp.status == 200) {
unset beresp.http.cache-control;
beresp.http.set-cookie;
set beresp.ttl = 3600s;
return(deliver);
}

Above example removes cache-control and set-cookie headers (by default Varnish will not cache responses that set cookies), sets TTL to 3600 seconds, and delivers response.

On 07/20/2017 02:14 PM, Girouard, Yanick wrote:
Hi,

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).

We have recently realized that one of our backend always set the following header: Cache-Control: max-age=0, private, must-revalidate

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.

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?

Is this even by design or is it a bug?

Thanks,
Yanick Girouard
RE: Varnish and max-age=0 [ In reply to ]
I found my issue... It had nothing to do with the max-age=0 after all, not with the way I was setting beresp.ttl either. I forgot to strip Set-Cookie from the backend response and that's why it wasn't caching... /facepalm.

Thanks for your help!

De : Bender, Charles [mailto:charles@beachcamera.com]
Envoy? : jeudi 20 juillet 2017 14:25
? : Girouard, Yanick <Yanick.Girouard@stm.info>; varnish-misc@varnish-cache.org
Objet : Re: Varnish and max-age=0


Yanick,

You may just need to set beresp.ttl to a value and Varnish should obey it. And possibly unset cookies. For example-
sub vcl_backend_response {
if (bereq.url ~ "somepage\.php" && beresp.status == 200) {
unset beresp.http.cache-control;
beresp.http.set-cookie;
set beresp.ttl = 3600s;
return(deliver);
}

Above example removes cache-control and set-cookie headers (by default Varnish will not cache responses that set cookies), sets TTL to 3600 seconds, and delivers response.
On 07/20/2017 02:14 PM, Girouard, Yanick wrote:
Hi,

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).

We have recently realized that one of our backend always set the following header: Cache-Control: max-age=0, private, must-revalidate

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.

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?

Is this even by design or is it a bug?

Thanks,
Yanick Girouard
Re: Varnish and max-age=0 [ In reply to ]
Just a thought, if you're going to force an otherwise uncacheable request
to be cached, you should probably: set beresp.uncacheable = false;



On Thu, Jul 20, 2017 at 9:03 PM, Girouard, Yanick <Yanick.Girouard@stm.info>
wrote:

> Hi Reza,
>
>
>
> Yes we are. Here's the default we apply. Those two subs are called in
> order in vcl_backend_response:
>
>
>
> /* REMOVE CACHE-CONTROL AND SURROGATE-CONTROL FROM BACKEND *
>
> ***********************************************************/
>
> sub stm_backend_resp_unset_cache_control_headers {
>
> unset beresp.http.Surrogate-Control;
>
> unset beresp.http.Cache-Control;
>
> unset beresp.http.Expires;
>
> }
>
>
>
> /* DEFAULT ALL TO: TTL 30MIN + GRACE 15MIN *
>
> *******************************************/
>
> sub stm_backend_resp_expiration_default {
>
> set beresp.ttl = 30m;
>
> set beresp.grace = 15m;
>
> }
>
>
>
> That doesn't seem to have any impact when the backend responds with a
> Cache-Control: max-age=0 header.
>
>
>
> Any idea?
>
>
>
>
>
> *De :* Reza Naghibi [mailto:reza@varnish-software.com]
> *Envoyé :* jeudi 20 juillet 2017 13:58
> *À :* Girouard, Yanick <Yanick.Girouard@stm.info>
> *Cc :* varnish-misc@varnish-cache.org
> *Objet :* Re: Varnish and max-age=0
>
>
>
> 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:
>
>
>
> sub vcl_backend_response
>
> {
>
> unset beresp.http.Cache-Control;
>
> set beresp.ttl = 120s;
>
> }
>
>
> --
> Reza Naghibi
> Varnish Software
>
>
>
> On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <
> Yanick.Girouard@stm.info> wrote:
>
> Hi,
>
>
>
> 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).
>
>
>
> We have recently realized that one of our backend always set the following
> header: *Cache-Control: max-age=0, private, must-revalidate*
>
>
>
> 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.
>
>
>
> 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?
>
>
>
> Is this even by design or is it a bug?
>
>
>
> Thanks,
>
> *Yanick Girouard*
>
>
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
RE: Varnish and max-age=0 [ In reply to ]
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?


________________________________
De : Andrei <lagged@gmail.com>
Envoy? : 20 juillet 2017 15:22
? : Girouard, Yanick
Cc : Reza Naghibi; varnish-misc@varnish-cache.org
Objet : Re: Varnish and max-age=0

Just a thought, if you're going to force an otherwise uncacheable request to be cached, you should probably: set beresp.uncacheable = false;



On Thu, Jul 20, 2017 at 9:03 PM, Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
Hi Reza,

Yes we are. Here's the default we apply. Those two subs are called in order in vcl_backend_response:

/* REMOVE CACHE-CONTROL AND SURROGATE-CONTROL FROM BACKEND *
***********************************************************/
sub stm_backend_resp_unset_cache_control_headers {
unset beresp.http.Surrogate-Control;
unset beresp.http.Cache-Control;
unset beresp.http.Expires;
}

/* DEFAULT ALL TO: TTL 30MIN + GRACE 15MIN *
*******************************************/
sub stm_backend_resp_expiration_default {
set beresp.ttl = 30m;
set beresp.grace = 15m;
}

That doesn't seem to have any impact when the backend responds with a Cache-Control: max-age=0 header.

Any idea?


De : Reza Naghibi [mailto:reza@varnish-software.com<mailto:reza@varnish-software.com>]
Envoy? : jeudi 20 juillet 2017 13:58
? : Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>>
Cc : varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
Objet : Re: Varnish and max-age=0

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:

sub vcl_backend_response
{
unset beresp.http.Cache-Control;
set beresp.ttl = 120s;
}

--
Reza Naghibi
Varnish Software

On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
Hi,

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).

We have recently realized that one of our backend always set the following header: Cache-Control: max-age=0, private, must-revalidate

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.

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?

Is this even by design or is it a bug?

Thanks,
Yanick Girouard


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Varnish and max-age=0 [ In reply to ]
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.

--
Guillaume Quintard

On Fri, Jul 21, 2017 at 12:09 AM, Girouard, Yanick <Yanick.Girouard@stm.info
> wrote:

> 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?
>
>
> ________________________________
> De : Andrei <lagged@gmail.com>
> Envoyé : 20 juillet 2017 15:22
> À : Girouard, Yanick
> Cc : Reza Naghibi; varnish-misc@varnish-cache.org
> Objet : Re: Varnish and max-age=0
>
> Just a thought, if you're going to force an otherwise uncacheable request
> to be cached, you should probably: set beresp.uncacheable = false;
>
>
>
> On Thu, Jul 20, 2017 at 9:03 PM, Girouard, Yanick <
> Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
> Hi Reza,
>
> Yes we are. Here's the default we apply. Those two subs are called in
> order in vcl_backend_response:
>
> /* REMOVE CACHE-CONTROL AND SURROGATE-CONTROL FROM BACKEND *
> ***********************************************************/
> sub stm_backend_resp_unset_cache_control_headers {
> unset beresp.http.Surrogate-Control;
> unset beresp.http.Cache-Control;
> unset beresp.http.Expires;
> }
>
> /* DEFAULT ALL TO: TTL 30MIN + GRACE 15MIN *
> *******************************************/
> sub stm_backend_resp_expiration_default {
> set beresp.ttl = 30m;
> set beresp.grace = 15m;
> }
>
> That doesn't seem to have any impact when the backend responds with a
> Cache-Control: max-age=0 header.
>
> Any idea?
>
>
> De : Reza Naghibi [mailto:reza@varnish-software.com<mailto:reza@varnish-
> software.com>]
> Envoyé : jeudi 20 juillet 2017 13:58
> À : Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.
> info>>
> Cc : varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
> Objet : Re: Varnish and max-age=0
>
> 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:
>
> sub vcl_backend_response
> {
> unset beresp.http.Cache-Control;
> set beresp.ttl = 120s;
> }
>
> --
> Reza Naghibi
> Varnish Software
>
> On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <
> Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
> Hi,
>
> 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).
>
> We have recently realized that one of our backend always set the following
> header: Cache-Control: max-age=0, private, must-revalidate
>
> 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.
>
> 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?
>
> Is this even by design or is it a bug?
>
> Thanks,
> Yanick Girouard
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
RE: Varnish and max-age=0 [ In reply to ]
So in which case would you want to force it to false? I read about it and it's mainly used to force a hit for pass, but I haven't read about a scenario where the opposite would be useful.

De : Guillaume Quintard [mailto:guillaume@varnish-software.com]
Envoyé : vendredi 21 juillet 2017 03:49
À : Girouard, Yanick <Yanick.Girouard@stm.info>
Cc : Andrei <lagged@gmail.com>; varnish-misc@varnish-cache.org
Objet : Re: Varnish and max-age=0

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.

--
Guillaume Quintard

On Fri, Jul 21, 2017 at 12:09 AM, Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
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?


________________________________
De : Andrei <lagged@gmail.com<mailto:lagged@gmail.com>>
Envoyé : 20 juillet 2017 15:22
À : Girouard, Yanick
Cc : Reza Naghibi; varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
Objet : Re: Varnish and max-age=0

Just a thought, if you're going to force an otherwise uncacheable request to be cached, you should probably: set beresp.uncacheable = false;



On Thu, Jul 20, 2017 at 9:03 PM, Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info><mailto:Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>>> wrote:
Hi Reza,

Yes we are. Here's the default we apply. Those two subs are called in order in vcl_backend_response:

/* REMOVE CACHE-CONTROL AND SURROGATE-CONTROL FROM BACKEND *
***********************************************************/
sub stm_backend_resp_unset_cache_control_headers {
unset beresp.http.Surrogate-Control;
unset beresp.http.Cache-Control;
unset beresp.http.Expires;
}

/* DEFAULT ALL TO: TTL 30MIN + GRACE 15MIN *
*******************************************/
sub stm_backend_resp_expiration_default {
set beresp.ttl = 30m;
set beresp.grace = 15m;
}

That doesn't seem to have any impact when the backend responds with a Cache-Control: max-age=0 header.

Any idea?


De : Reza Naghibi [mailto:reza@varnish-software.com<mailto:reza@varnish-software.com><mailto:reza@varnish-software.com<mailto:reza@varnish-software.com>>]
Envoyé : jeudi 20 juillet 2017 13:58
À : Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info><mailto:Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>>>
Cc : varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org><mailto:varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>>
Objet : Re: Varnish and max-age=0

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:

sub vcl_backend_response
{
unset beresp.http.Cache-Control;
set beresp.ttl = 120s;
}

--
Reza Naghibi
Varnish Software

On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info><mailto:Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>>> wrote:
Hi,

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).

We have recently realized that one of our backend always set the following header: Cache-Control: max-age=0, private, must-revalidate

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.

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?

Is this even by design or is it a bug?

Thanks,
Yanick Girouard


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org><mailto:varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org><mailto:varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Varnish and max-age=0 [ In reply to ]
beresp.uncacheable == false is the default, ie. "cache the object and serve
it next time someone ask for it"

--
Guillaume Quintard

On Fri, Jul 21, 2017 at 2:17 PM, Girouard, Yanick <Yanick.Girouard@stm.info>
wrote:

> So in which case would you want to force it to false? I read about it and
> it's mainly used to force a hit for pass, but I haven't read about a
> scenario where the opposite would be useful.
>
>
>
> *De :* Guillaume Quintard [mailto:guillaume@varnish-software.com]
> *Envoyé :* vendredi 21 juillet 2017 03:49
> *À :* Girouard, Yanick <Yanick.Girouard@stm.info>
> *Cc :* Andrei <lagged@gmail.com>; varnish-misc@varnish-cache.org
>
> *Objet :* Re: Varnish and max-age=0
>
>
>
> 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.
>
>
> --
>
> Guillaume Quintard
>
>
>
> On Fri, Jul 21, 2017 at 12:09 AM, Girouard, Yanick <
> Yanick.Girouard@stm.info> wrote:
>
> 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?
>
>
> ________________________________
> De : Andrei <lagged@gmail.com>
> Envoyé : 20 juillet 2017 15:22
> À : Girouard, Yanick
> Cc : Reza Naghibi; varnish-misc@varnish-cache.org
> Objet : Re: Varnish and max-age=0
>
> Just a thought, if you're going to force an otherwise uncacheable request
> to be cached, you should probably: set beresp.uncacheable = false;
>
>
>
> On Thu, Jul 20, 2017 at 9:03 PM, Girouard, Yanick <
> Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
> Hi Reza,
>
> Yes we are. Here's the default we apply. Those two subs are called in
> order in vcl_backend_response:
>
> /* REMOVE CACHE-CONTROL AND SURROGATE-CONTROL FROM BACKEND *
> ***********************************************************/
> sub stm_backend_resp_unset_cache_control_headers {
> unset beresp.http.Surrogate-Control;
> unset beresp.http.Cache-Control;
> unset beresp.http.Expires;
> }
>
> /* DEFAULT ALL TO: TTL 30MIN + GRACE 15MIN *
> *******************************************/
> sub stm_backend_resp_expiration_default {
> set beresp.ttl = 30m;
> set beresp.grace = 15m;
> }
>
> That doesn't seem to have any impact when the backend responds with a
> Cache-Control: max-age=0 header.
>
> Any idea?
>
>
> De : Reza Naghibi [mailto:reza@varnish-software.com<mailto:reza@varnish-
> software.com>]
> Envoyé : jeudi 20 juillet 2017 13:58
> À : Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.
> info>>
> Cc : varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
> Objet : Re: Varnish and max-age=0
>
> 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:
>
> sub vcl_backend_response
> {
> unset beresp.http.Cache-Control;
> set beresp.ttl = 120s;
> }
>
> --
> Reza Naghibi
> Varnish Software
>
> On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <
> Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
> Hi,
>
> 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).
>
> We have recently realized that one of our backend always set the following
> header: Cache-Control: max-age=0, private, must-revalidate
>
> 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.
>
> 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?
>
> Is this even by design or is it a bug?
>
> Thanks,
> Yanick Girouard
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
>
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
>
RE: Varnish and max-age=0 [ In reply to ]
Thanks but that doesn't really answer my question. Being the default, you'd only want to set it to false explicitly if it was set to true. My question was when would you ever want or need to do this? I can see cases where you'd want to force it to true, but not the opposite.


De : Guillaume Quintard [mailto:guillaume@varnish-software.com]
Envoyé : vendredi 21 juillet 2017 08:38
À : Girouard, Yanick <Yanick.Girouard@stm.info>
Cc : Andrei <lagged@gmail.com>; varnish-misc@varnish-cache.org
Objet : Re: Varnish and max-age=0

beresp.uncacheable == false is the default, ie. "cache the object and serve it next time someone ask for it"

--
Guillaume Quintard

On Fri, Jul 21, 2017 at 2:17 PM, Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
So in which case would you want to force it to false? I read about it and it's mainly used to force a hit for pass, but I haven't read about a scenario where the opposite would be useful.

De : Guillaume Quintard [mailto:guillaume@varnish-software.com<mailto:guillaume@varnish-software.com>]
Envoyé : vendredi 21 juillet 2017 03:49
À : Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>>
Cc : Andrei <lagged@gmail.com<mailto:lagged@gmail.com>>; varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>

Objet : Re: Varnish and max-age=0

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.

--
Guillaume Quintard

On Fri, Jul 21, 2017 at 12:09 AM, Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
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?


________________________________
De : Andrei <lagged@gmail.com<mailto:lagged@gmail.com>>
Envoyé : 20 juillet 2017 15:22
À : Girouard, Yanick
Cc : Reza Naghibi; varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
Objet : Re: Varnish and max-age=0

Just a thought, if you're going to force an otherwise uncacheable request to be cached, you should probably: set beresp.uncacheable = false;



On Thu, Jul 20, 2017 at 9:03 PM, Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info><mailto:Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>>> wrote:
Hi Reza,

Yes we are. Here's the default we apply. Those two subs are called in order in vcl_backend_response:

/* REMOVE CACHE-CONTROL AND SURROGATE-CONTROL FROM BACKEND *
***********************************************************/
sub stm_backend_resp_unset_cache_control_headers {
unset beresp.http.Surrogate-Control;
unset beresp.http.Cache-Control;
unset beresp.http.Expires;
}

/* DEFAULT ALL TO: TTL 30MIN + GRACE 15MIN *
*******************************************/
sub stm_backend_resp_expiration_default {
set beresp.ttl = 30m;
set beresp.grace = 15m;
}

That doesn't seem to have any impact when the backend responds with a Cache-Control: max-age=0 header.

Any idea?


De : Reza Naghibi [mailto:reza@varnish-software.com<mailto:reza@varnish-software.com><mailto:reza@varnish-software.com<mailto:reza@varnish-software.com>>]
Envoyé : jeudi 20 juillet 2017 13:58
À : Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info><mailto:Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>>>
Cc : varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org><mailto:varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>>
Objet : Re: Varnish and max-age=0

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:

sub vcl_backend_response
{
unset beresp.http.Cache-Control;
set beresp.ttl = 120s;
}

--
Reza Naghibi
Varnish Software

On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info><mailto:Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>>> wrote:
Hi,

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).

We have recently realized that one of our backend always set the following header: Cache-Control: max-age=0, private, must-revalidate

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.

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?

Is this even by design or is it a bug?

Thanks,
Yanick Girouard


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org><mailto:varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org><mailto:varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Varnish and max-age=0 [ In reply to ]
Ah, right, indeed. Unless you set it to true for some set of URLs, and to
false again for a subset of it. That could make your VCL clearer, maybe

--
Guillaume Quintard

On Fri, Jul 21, 2017 at 2:42 PM, Girouard, Yanick <Yanick.Girouard@stm.info>
wrote:

> Thanks but that doesn't really answer my question. Being the default,
> you'd only want to set it to false explicitly if it was set to true. My
> question was when would you ever want or need to do this? I can see cases
> where you'd want to force it to true, but not the opposite.
>
>
>
>
>
> *De :* Guillaume Quintard [mailto:guillaume@varnish-software.com]
> *Envoyé :* vendredi 21 juillet 2017 08:38
>
> *À :* Girouard, Yanick <Yanick.Girouard@stm.info>
> *Cc :* Andrei <lagged@gmail.com>; varnish-misc@varnish-cache.org
> *Objet :* Re: Varnish and max-age=0
>
>
>
> beresp.uncacheable == false is the default, ie. "cache the object and
> serve it next time someone ask for it"
>
>
> --
>
> Guillaume Quintard
>
>
>
> On Fri, Jul 21, 2017 at 2:17 PM, Girouard, Yanick <
> Yanick.Girouard@stm.info> wrote:
>
> So in which case would you want to force it to false? I read about it and
> it's mainly used to force a hit for pass, but I haven't read about a
> scenario where the opposite would be useful.
>
>
>
> *De :* Guillaume Quintard [mailto:guillaume@varnish-software.com]
> *Envoyé :* vendredi 21 juillet 2017 03:49
> *À :* Girouard, Yanick <Yanick.Girouard@stm.info>
> *Cc :* Andrei <lagged@gmail.com>; varnish-misc@varnish-cache.org
>
>
> *Objet :* Re: Varnish and max-age=0
>
>
>
> 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.
>
>
> --
>
> Guillaume Quintard
>
>
>
> On Fri, Jul 21, 2017 at 12:09 AM, Girouard, Yanick <
> Yanick.Girouard@stm.info> wrote:
>
> 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?
>
>
> ________________________________
> De : Andrei <lagged@gmail.com>
> Envoyé : 20 juillet 2017 15:22
> À : Girouard, Yanick
> Cc : Reza Naghibi; varnish-misc@varnish-cache.org
> Objet : Re: Varnish and max-age=0
>
> Just a thought, if you're going to force an otherwise uncacheable request
> to be cached, you should probably: set beresp.uncacheable = false;
>
>
>
> On Thu, Jul 20, 2017 at 9:03 PM, Girouard, Yanick <
> Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
> Hi Reza,
>
> Yes we are. Here's the default we apply. Those two subs are called in
> order in vcl_backend_response:
>
> /* REMOVE CACHE-CONTROL AND SURROGATE-CONTROL FROM BACKEND *
> ***********************************************************/
> sub stm_backend_resp_unset_cache_control_headers {
> unset beresp.http.Surrogate-Control;
> unset beresp.http.Cache-Control;
> unset beresp.http.Expires;
> }
>
> /* DEFAULT ALL TO: TTL 30MIN + GRACE 15MIN *
> *******************************************/
> sub stm_backend_resp_expiration_default {
> set beresp.ttl = 30m;
> set beresp.grace = 15m;
> }
>
> That doesn't seem to have any impact when the backend responds with a
> Cache-Control: max-age=0 header.
>
> Any idea?
>
>
> De : Reza Naghibi [mailto:reza@varnish-software.com<mailto:reza@varnish-
> software.com>]
> Envoyé : jeudi 20 juillet 2017 13:58
> À : Girouard, Yanick <Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.
> info>>
> Cc : varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
> Objet : Re: Varnish and max-age=0
>
> 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:
>
> sub vcl_backend_response
> {
> unset beresp.http.Cache-Control;
> set beresp.ttl = 120s;
> }
>
> --
> Reza Naghibi
> Varnish Software
>
> On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <
> Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
> Hi,
>
> 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).
>
> We have recently realized that one of our backend always set the following
> header: Cache-Control: max-age=0, private, must-revalidate
>
> 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.
>
> 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?
>
> Is this even by design or is it a bug?
>
> Thanks,
> Yanick Girouard
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
>
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
>
>
>
Re: Varnish and max-age=0 [ In reply to ]
Setting to false is a no-op iirc. Once true, you can no longer bend the
truth.

On Jul 21, 2017 17:29, "Guillaume Quintard" <guillaume@varnish-software.com>
wrote:

Ah, right, indeed. Unless you set it to true for some set of URLs, and to
false again for a subset of it. That could make your VCL clearer, maybe

--
Guillaume Quintard

On Fri, Jul 21, 2017 at 2:42 PM, Girouard, Yanick <Yanick.Girouard@stm.info>
wrote:

> Thanks but that doesn't really answer my question. Being the default,
> you'd only want to set it to false explicitly if it was set to true. My
> question was when would you ever want or need to do this? I can see cases
> where you'd want to force it to true, but not the opposite.
>
>
>
>
>
> *De :* Guillaume Quintard [mailto:guillaume@varnish-software.com]
> *Envoyé :* vendredi 21 juillet 2017 08:38
>
> *À :* Girouard, Yanick <Yanick.Girouard@stm.info>
> *Cc :* Andrei <lagged@gmail.com>; varnish-misc@varnish-cache.org
> *Objet :* Re: Varnish and max-age=0
>
>
>
> beresp.uncacheable == false is the default, ie. "cache the object and
> serve it next time someone ask for it"
>
>
> --
>
> Guillaume Quintard
>
>
>
> On Fri, Jul 21, 2017 at 2:17 PM, Girouard, Yanick <
> Yanick.Girouard@stm.info> wrote:
>
> So in which case would you want to force it to false? I read about it and
> it's mainly used to force a hit for pass, but I haven't read about a
> scenario where the opposite would be useful.
>
>
>
> *De :* Guillaume Quintard [mailto:guillaume@varnish-software.com]
> *Envoyé :* vendredi 21 juillet 2017 03:49
> *À :* Girouard, Yanick <Yanick.Girouard@stm.info>
> *Cc :* Andrei <lagged@gmail.com>; varnish-misc@varnish-cache.org
>
>
> *Objet :* Re: Varnish and max-age=0
>
>
>
> 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.
>
>
> --
>
> Guillaume Quintard
>
>
>
> On Fri, Jul 21, 2017 at 12:09 AM, Girouard, Yanick <
> Yanick.Girouard@stm.info> wrote:
>
> 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?
>
>
> ________________________________
> De : Andrei <lagged@gmail.com>
> Envoyé : 20 juillet 2017 15:22
> À : Girouard, Yanick
> Cc : Reza Naghibi; varnish-misc@varnish-cache.org
> Objet : Re: Varnish and max-age=0
>
> Just a thought, if you're going to force an otherwise uncacheable request
> to be cached, you should probably: set beresp.uncacheable = false;
>
>
>
> On Thu, Jul 20, 2017 at 9:03 PM, Girouard, Yanick <
> Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
> Hi Reza,
>
> Yes we are. Here's the default we apply. Those two subs are called in
> order in vcl_backend_response:
>
> /* REMOVE CACHE-CONTROL AND SURROGATE-CONTROL FROM BACKEND *
> ***********************************************************/
> sub stm_backend_resp_unset_cache_control_headers {
> unset beresp.http.Surrogate-Control;
> unset beresp.http.Cache-Control;
> unset beresp.http.Expires;
> }
>
> /* DEFAULT ALL TO: TTL 30MIN + GRACE 15MIN *
> *******************************************/
> sub stm_backend_resp_expiration_default {
> set beresp.ttl = 30m;
> set beresp.grace = 15m;
> }
>
> That doesn't seem to have any impact when the backend responds with a
> Cache-Control: max-age=0 header.
>
> Any idea?
>
>
> De : Reza Naghibi [mailto:reza@varnish-software.com<mailto:
> reza@varnish-software.com>]
> Envoyé : jeudi 20 juillet 2017 13:58
> À : Girouard, Yanick <Yanick.Girouard@stm.info<mailto:
> Yanick.Girouard@stm.info>>
> Cc : varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
> Objet : Re: Varnish and max-age=0
>
> 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:
>
> sub vcl_backend_response
> {
> unset beresp.http.Cache-Control;
> set beresp.ttl = 120s;
> }
>
> --
> Reza Naghibi
> Varnish Software
>
> On Thu, Jul 20, 2017 at 1:44 PM, Girouard, Yanick <
> Yanick.Girouard@stm.info<mailto:Yanick.Girouard@stm.info>> wrote:
> Hi,
>
> 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).
>
> We have recently realized that one of our backend always set the following
> header: Cache-Control: max-age=0, private, must-revalidate
>
> 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.
>
> 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?
>
> Is this even by design or is it a bug?
>
> Thanks,
> Yanick Girouard
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org<mailto:varnish-misc@varnish-cache.org>
>
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>
>
>
>


_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc