Varnish to cache accordingly by inspecting Backend response header

Reinis Rozitis r at roze.lv
Tue Mar 12 12:51:14 CET 2013


> I was wondering if it's possible to let Varnish to cache based on Backend 
> server response header?
> For example, if Backend response header has "cache_ttl = 60", then Varnish 
> will cache it for 60 seconds.
> If the cache_ttl = 0 or is not exist in Backend, Varnish will not cache 
> for that object at all.

This is how varnish works by default  - it respects the  max-age, 
Cache-Control fields and Expires headers.

You can override it in vcl_fetch by changing the beresp.ttl. For example:

if (beresp.ttl < 5m) {
         set beresp.ttl = 5m;
}



rr 




More information about the varnish-misc mailing list