Varnish caching 503 error pages

Ken Brownfield kb+varnish at slide.com
Tue Feb 2 22:52:54 CET 2010


If your default_ttl is not 0, then this may be the expected behavior.  I'm not sure if Varnish should really ever cache >=500 responses?

But in VCL you could do something like:

sub vcl_fetch {
	if ( obj.status >= 500 ) {
		set obj.ttl = 0s;
		set obj.cacheable = false;
	}
}

Adjusting timeouts for ttl for 404s is also handy.  Hope it helps,
-- 
Ken

On Feb 2, 2010, at 1:37 PM, pub crawler wrote:

> Thought I'd ask the list before I went on a voyage with this one.
> 
> Sometime our backend app servers gets overloaded and go into
> protection mode whereby they sends out 503 errors until they recover.
> 
> Varnish is in front of the app servers and when this happens the 503
> ends up as a cached item in Varnish.
> 
> Here's output to show such:
> 
> HTTP/1.1 503 Service Unavailable
> Keep-Alive: timeout=30
> Content-Type: text/html
> Content-Language: en-US
> Content-Length: 122
> Date: Tue, 02 Feb 2010 21:34:15 GMT
> X-Varnish: 655791101 655790499
> Age: 97
> Via: 1.1 varnish
> Connection: keep-alive
> X-Served-By: atom3302
> X-Cache: HIT
> X-Cache-Hits: 13
> 
> What is the best way to explicitly refuse caching of 503 errors by Varnish?
> 
> Thanks!
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-misc



More information about the varnish-misc mailing list