Fastly caches the following response status codes by default. In addition to these statuses, you can force an object to cache under other states using conditions and responses.
Code | Message |
---|---|
200 |
OK |
203 |
Non-Authoritative Information |
300 |
Multiple Choices |
301 |
Moved Permanently |
302 |
Moved Temporarily |
404 |
Not Found |
410 |
Gone |
To cache status codes other than the ones listed above, set beresp.cacheable = true;
in vcl_fetch
. This tells Varnish to obey backend HTTP caching headers and any other custom ttl
logic. A common pattern is to allow all 2XX responses to be cacheable:
1
2
3
4
5
6
7
sub vcl_fetch {
# ...
if (beresp.status >= 200 && beresp.status < 300) {
set beresp.cacheable = true;
}
# ...
}