Categories

Varnish: Do not cache 404 error pages

Written by Guillermo Garron .
Date: 2013-01-15 15:00:13 +0000

If Varnish Cache is caching 404 error code pages from the backend, you can change this behaviour by adding this to the vcl

In the vcl_fetch section add this:

if (beresp.status == 404) { 
    	set beresp.ttl = 30s; 
    }

You can change 30s to 0s if you do not want to cache 404 error codes at all.

I prefer to cache them for a short period of time, that way I can protect my back end from dealing with that load.



Bio.

My name is Guillermo Garron. I am telecommunications engineer from Bolivia

I like technology a lot, and this site is mainly dedicated to that

Social feeds

rss | twitter | email | google+