We have a service that returns 503 errors with Cache-Control: max-age=X. In 
Varnish 2 it was easy to get it to cache and get the appropriate ttl with a 
block like this: 

sub vcl_fetch {
if (beresp.status == 503) {

set beresp.cacheable = true;
}
}

Now that beresp.cacheable is removed in varnish 3, how do I set beresp.ttl to 
the contents of Cache-Control: max-age? 

This is the best I've come up with so far, but it doesn't take Age into account 
and it's a bit ugly in my opinion:
if (beresp.status == 503 && beresp.http.Cache-Control ~ "max-age") {

set beresp.ttl = std.duration(regsub(beresp.http.Cache-Control, 
"^.*max-age=([0-9]+).*$", "\1s"), 1s);
}


Does anyone have a better solution?

-- kent



_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to