*.keep and if-modified-since

Rich Rauenzahn rrauenza at gmail.com
Mon May 2 21:45:57 CEST 2011


I can't seem to get this to work (keeping a file around if its
if-modified-since hasn't changed) -- I'm also having a hard time
validating whether it is working or not.

Right now I observe that the file is taking longer to download, so I
assume it is pulling the entire file again from the apache backend.
(I also see new entries in the apache log -- but I'm unclear if those
would also occur with the if-modified-since header.)   I'm also
unclear what to look for in the varnish log.

This is what I have right now for my vcl:

backend build_download1 {
  .host = "build-download1";
  .port = "80";
}

sub vcl_recv {
    #set req.ttl   = 1d;
    #set req.grace = 1h;
    #set req.keep  = 365d;
}

sub vcl_fetch {
    set beresp.ttl   = 1m; # lower to 1m for testing.
    set beresp.grace = 1h;
    set beresp.keep  = 365d;
}

sub vcl_hit {
    #set obj.ttl   = 1d;
    #set obj.grace = 1h;
    #set obj.keep  = 365d;
}

I've looked at the diagram of the vcl subroutines, and I'm still
having trouble figuring out where to put the timeouts.

What I want is for an object never to be thrown out if the file has
not been modified on the backend (if it is removed, I want it to
expire, obviously)

For grace, I want to always serve an old file rather than wait (so 1
hour should be enough).

For TTL, I want to keep objects around for 12 hours before checking
the if-modified timestamp.  I also would want to set the frequency at
which it checks if-modified after that as well -- so I would want to
reset the TTL (maybe to 6 hours?) after an if-modified check.

Anyone have some advice or further documentation to look at?

I've looked at:

http://www.varnish-cache.org/trac/wiki/BackendConditionalRequests
http://www.varnish-cache.org/trac/wiki/VCL
http://www.varnish-cache.org/trac/wiki/VCLExampleDefault

Thanks,
Rich




More information about the varnish-misc mailing list