influencing beresp.cacheable on the backend
David Birdsong
david.birdsong at gmail.com
Mon Apr 12 23:50:42 CEST 2010
How can I influence bereps.cacheable in a backend such that it will
evaluate to False?
I set Expires and Cache-Control in the backend, this is what the
backend generates:
HTTP/1.1 200 OK
Server: nginx/0.7.65
Date: Mon, 12 Apr 2010 21:48:25 GMT
Content-Type: image/gif
Content-Length: 43
Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT
Connection: close
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Cache-Control: no-cache
>From the man page:
"""
A response is considered cacheable if it is valid (see above), the
HTTP status code is 200, 203, 300, 301, 302, 404 or 410 and it has a
non-zero time-to-live when Expires and Cache-Control headers are taken
into account.
"""
And yet this object is getting cached in varnish. Here is my vcl_fetch:
sub vcl_fetch {
if (beresp.http.Set-Cookie) {
unset beresp.http.Set-Cookie;
}
if (beresp.cacheable) {
unset beresp.http.expires;
set beresp.ttl = 1h;
if (beresp.status >= 300 && beresp.status <= 399) {
set beresp.ttl = 10m;
}
if (beresp.status >= 399) {
set beresp.ttl = 0s;
}
}
remove beresp.http.X-Varnish-IP;
remove beresp.http.X-Varnish-Port;
}
More information about the varnish-misc
mailing list