Different Caching Durations For Varnish and Client

Demitrious Kelly apokalyptik at apokalyptik.com
Wed Jul 16 19:55:38 CEST 2008

We're actually thinking about the possibility of scrubbing 
Cache-Control, Age, and Expires on the varnish output, and using NGINX 
(already our load balancer in front of varnish) to programatically set 
an expires header for the client on the way out.  Of course it would be 
much cleaner, and less human-error-prone if we could do something like 
this in vcl_deliver:

set res.http.Expires = 300;

Nobody would have to remember that one last piece of it was hanging out 
in the load balancer...


Audun Ytterdal wrote:
> Demitrious Kelly wrote:
>> Hey guys!
>> Lets sat I have some dynamically generated content that I would like
>> varnish to cache for, say a month.  When this content is updated I'm
>> invalidating the cache via a url.purge.  I therefor want the world
>> outside to check back in with varnish every 10 minutes.
>> So in the response to varnish I have set the Expires to be 1 month from
>> the request, and in the vcl I'm doing the following:
>> sub vcl_deliver {
>>     remove resp.http.Expires;
>>     remove resp.http.Cache-Control;
>>     remove resp.http.Age;
>>     set resp.http.Cache-Control = "max-age=600, proxy-revalidate";
>>     set resp.http.Age = "0";
>>     deliver;
>> }
>> The problem is that this feels like the wrong way to be approaching the
>> problem, and doesn't seem very "correct" as far as HTTP protocol
>> observance is concerned. What would be the best way to implement such a
>> scenario?
>> Secondarily is there any nifty mechanism for generating an expires
>> header with the VCL? I would imagine that the cleanest way to do this
>> would be to drop the cache-control idea and go with an expires always
>> set to 600 seconds from now on the vcl_deliver.
> You could use smax-age instead of max-age. smax-age is shared cache max
> time.
> varnish uses smax-age and max-age. Only problem is that any other shared
> caches (such as a local squid in front of the client) also would use
> smax-age
> I would also like som sort of "max-age, only for varnish"-header.
> --
> Audun
> *****************************************************************
> Denne fotnoten bekrefter at denne e-postmeldingen ble
> skannet av MailSweeper og funnet fri for virus.
> *****************************************************************
> This footnote confirms that this email message has been 
> swept by MailSweeper for the presence of computer viruses.
> *****************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20080716/df20a18a/attachment-0001.html>

More information about the varnish-misc mailing list