There are times when certain pages need to avoid being cached, and they all have the following response header set by the backend:
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
Varnish, however, happily caches these pages nonetheless. Is there something I can add to the config to prevent this? I'm guessing it's something that should go into vcl_deliver
or vcl_fetch
subroutines, but the documentation isn't very helpful (to me anyway).
Basically looking for something like this but in reverse - should check headers on the response.
Varnish is version 3.0 (no, can't upgrade right now)
Relevant config:
sub vcl_fetch {
if (req.http.X-Varnish-Use-Cache && beresp.status != 500) {
set beresp.ttl = 24h;
set beresp.do_esi = true;
unset beresp.http.Set-Cookie;
}
return (deliver);
}
sub vcl_deliver {
if(!resp.http.X-Cache) {
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
} else {
if (obj.hits > 0) {
set resp.http.X-Cache = resp.http.X-Cache + ", HIT";
} else {
set resp.http.X-Cache = resp.http.X-Cache + ", MISS";
}
}
set resp.http.X-Flavour = req.http.X-Flavour;
return (deliver);
}