Handling 400's without saint mode
Lasse Karstensen
lkarsten at varnish-software.com
Wed Jul 16 15:12:11 CEST 2014
On Wed, Jul 16, 2014 at 08:05:15AM -0400, maillists0 at gmail.com wrote:
> Using Varnish 3.x to retrieve objects from s3. Due to a release process
> that is beyond my control, some items are occasionally unavailable for 3 to
> 5 minutes when they're being recreated. Saint mode doesn't seem to do what
> I need here.
> What I really want is to check the backend first and then serve from cache
> on a 400 for each request to this backend. Is that possible with Saint
> mode, or is there a better way to do this?
Saint mode and grace should help you out here.
Something like this could perhaps work:
backend s3server {
.host = ..
.saintmode_threshold = 999999999;
}
sub vcl_recv {
set req.grace = 10m;
}
sub vcl_fetch {
set beresp.grace = 10m;
if (req.backend == s3server && beresp.status == 400) {
set beresp.saintmode = 300s;
return(restart);
}
}
Any URLs giving a 400s from s3server is then marked as sick for 300s.
As long as there is an old version of the object still in cache, give
that to this and any clients asking for this URL for the next 300s.
--
Lasse Karstensen
Varnish Software AS
More information about the varnish-misc
mailing list