Determine if grace object is available

Lasse Karstensen lkarsten at varnish-software.com
Wed Jul 23 15:03:44 CEST 2014


On Mon, Jul 21, 2014 at 04:35:25PM -0500, Kevin Day wrote:
> I’d like to get fancy with grace stored objects, but I’m not sure how to do this. Can I determine if there’s a grace object I could deliver? Basically I want my logic to be:
> 1) If the backend returns a 200, cache and deliver as normal.
> 2) If the backend returns anything other than a 200, and I have a stale object I could serve anyway, serve it.
> 3) If the backend returns anything other than a 200, restart to redirect to a final fallback.
> I know how to do #1 and #3, but I’m not sure where/how I can do #2. Is there a way of determining if I could fallback to a stale object? If so, any pointers?

You can do (2) with saint mode and a restart:

    https://www.varnish-cache.org/docs/3.0/tutorial/handling_misbehaving_servers.html#saint-mode


If this fails, because you didn't have a stale object available, you can
do (3) via vcl_error automatically.

-- 
Lasse Karstensen
Varnish Software AS



More information about the varnish-misc mailing list