how storing objects for a given time, regardless of expire info from back-end?

Richard Chiswell richard.chiswell at
Mon Apr 12 18:23:48 CEST 2010

You'll want something like:

sub vcl_fetch {
unset obj.http.Expires;
unset obj.http.Cache-Control;
set obj.ttl = 60m; // cache for 60 minutes within Varnish
set obj.http.Cache-Control = "public, max-age=2678400"; // cache for 31 
days at User end

However, depending on exactly what you want to cache for who and for how 
long (do you want to cache things for people with cookies? do you really 
want to cache a 1Gb .avi file within Varnish? etc), the configuration 
can get a bit complex.


On 12/04/2010 17:18, Dirk Taggesell wrote:
> Hi all,
> I am just trying to get familiar with varnish. I installed the latest
> version 2.1.0 and with the minimal config it works as intended:
> backend default {
>      .host = "";
>      .port = "80";
> }
> But the back-end sends an expires-header of "0", thus varnish tries to
> fetch the item again from the back-end for every client requesting it.
> So I need a simple rule that tells varnish to just cache every object
> for say 2h, regardless what the back-end says. I just have to prevent
> varnish to ask the back-end at every request.
> Unfortunately the config language is not entirely self-explaining. and
> most expamples on the web won't work (too old?).
> Can anyone help me?

More information about the varnish-misc mailing list