Different Caching Durations For Varnish and Client

Demitrious Kelly apokalyptik at apokalyptik.com
Tue Jul 15 02:04:05 CEST 2008

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";

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 

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.


More information about the varnish-misc mailing list