简体   繁体   English

没有缓存控制标头的清漆行为

[英]Varnish behavior for no cache-control header

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. 我想知道:如果我的应用程序当前未发送任何cache-control标头,那么清漆缓存的行为是什么。 Does it cache anyway or we need to explicitly send cache-control header with max-age value so that varnish can cache that. 它仍然缓存还是我们需要显式发送具有max-age值的cache-control标头,以便清漆可以缓存它。 I have set up varnish to cache 200, 404, 400 status code response. 我已将清漆设置为缓存200、404、400状态码响应。 Thanks. 谢谢。

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 a Set-Cookie header. 这取决于许多因素:Varnish 不会在客户端发送Coookie标头的地方,或者服务器发送带有Set-Cookie标头的响应的地方, 缓存任何请求。 You also can't cache POST requests as they are not idempotent. 您也不能缓存POST请求,因为它们不是幂等的。

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. 这就是说,如果请求没有附带饼干,是一个GET请求,清漆被设定为高速缓存默认120秒的请求。 This is determined by the default_ttl setting in varnish, and again would only apply to requests that are cache-able in varnish (even without setting a cache-control header). 这由varnish中的default_ttl设置确定,同样仅适用于在varnish中可缓存的请求(即使未设置cache-control标头)。

From the Varnish documentation: 从Varnish文档中:

The Cache-Control header can contain a number of headers. Cache-Control标头可以包含许多标头。 Varnish evaluates it and looks for s-maxage and max-age. Varnish对其进行评估,并寻找s-maxage和max-age。 It will set the TTL to the value of s-maxage if found. 如果找到,它将TTL设置为s-maxage的值。 If s-maxage isn't found, it will use max-age. 如果找不到s-maxage,它将使用max-age。 If neither exist, it will use the Expires header to set the ttl. 如果都不存在,它将使用Expires标头设置ttl。 If none of those headers exist, it will use the default TTL 如果这些标头都不存在,它将使用默认的TTL

https://www.varnish-software.com/static/book/VCL_Basics.html https://www.varnish-software.com/static/book/VCL_Basics.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM