I am just setting up varnish for my team. And i want to know: if my application does not currently send any cache-control
header then what is the behavior of the varnish cache. Does it cache anyway or we need to explicitly send cache-control
header with max-age
value so that varnish can cache that. I have set up varnish to cache 200, 404, 400 status code response. Thanks.
Varnish behavior for no cache-control header
1.2k views Asked by Trying At
1
This depends on a number of factors: Varnish will not cache any requests where the client sends a
Coookie
header, or if the server sends a response with aSet-Cookie
header. You also can't cachePOST
requests as they are not idempotent.That said, if a request does not have cookies attached, and is a
GET
request, varnish is set to cache a request for 120s by default. This is determined by thedefault_ttl
setting in varnish, and again would only apply to requests that are cache-able in varnish (even without setting acache-control
header).From the Varnish documentation:
https://www.varnish-software.com/static/book/VCL_Basics.html