Different Caching Durations For Varnish and Client

Audun Ytterdal ay at vg.no
Tue Jul 15 10:49:09 CEST 2008


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




More information about the varnish-misc mailing list