honoring browser reload request

Lapo Luchini lapo at lapo.it
Tue Jun 17 14:11:56 CEST 2008


Using latest varnish from FreeBSD ports (version 1.1.2), is the 
following VCL the "correct" solution to support browser shift-reloads to 
get fresh content and actually update the cache?

sub vcl_hit {
     if (req.http.Cache-Control ~ "no-cache") {
         set obj.ttl = 0s;
         pass;
     }
}

As far as I understood vcl(7), this means:
1. fetch the object from cache (implicit in the fact that we're inside 
vcl_hit)
2. set ttl to 0s, expiring it (so next requests will fetch new content)
3. pass to backend (so *this* request see new content)

Does this do what I expect it to do?
Is there a way to avoid hitting the backend twice?
Is there a way to do that in vcl_recv?
(I guess not, since there's no "obj" object available yet, there)
I guess I could use purge_url(...), except I have virtual hosts and it 
wants a regexp and req.url could contain some special char (could it?).

-- 
Lapo Luchini - http://lapo.it/




More information about the varnish-misc mailing list