views:

813

answers:

4

I'm looking for a caching reverse proxy (something like squid or varnish) with good support for serving stale content in the event of failure - in other words, if the application I'm proxying goes away or starts serving internal server errors I'd like the cache to continue to serve the last good response saved from the back end. Essentially I want the cache server to act as an extra layer of protection should something go wrong.

Has anyone configured Squid or similar to do this? Know of any products that support this out of the box?

A: 

Try varnish.

Keltia
+3  A: 

It looks like Varnish can't handle this requirement just yet: http://varnish.projects.linpro.no/ticket/369

Simon Willison
For anyone reading this now, the ticket has been closed and marked fixed 4 months after Simon's answer. Apparently this feature is now known as "saint mode".
Frank Farmer
+1  A: 

It would depend on how long 'unavailable' is. Squid has a config 'refresh_stale_hit' which is mostly designed to remove some latency by allowing slightly stale content to be served while the cache is updated. Pretty sure it won't override getting a bad response from the web server, though. There is a full-on 'offline' mode that will keep serving cached results (designed for ... wait for it ... offline use!) so the code paths are in there: not sure if you can configure it to both proxy good results, and ignore bad ones.

reedstrm
+5  A: 

Squid can do this in version 2.7. Specifically, use the stale-if-error directive. More details can be found at:

http://www.mnot.net/blog/2007/12/12/stale

Tim