简体   繁体   English

如果标记为public,是否应该设置Cache-Control max-age?

[英]Should Cache-Control max-age be set if marked public?

I was trying to figure out the best cache headers for my site and couldn't find a good resource about setting both max-age and public . 我试图找出适合我网站的最佳缓存头,却找不到有关设置max-agepublic的好资源。

In my situation I have a number of files where I am not worried about them expiring, if I were to set max-age it would probably be a month or year. 在我的情况下,我有许多文件不用担心它们会过期,如果我要设置最大使用期限,则可能是一个月或一年。 But my question is, should the max-age be omitted, and just specify Cache-Control: public ? 但是我的问题是,应该省略max-age ,而仅指定Cache-Control: public吗? Isn't that essentially saying "cache for as long as you can"? 这不是在说“尽可能长时间地缓存”吗?

TL;DR Are there any advantages/disadvantages to setting max-age if public is set and the objects have an indefinite expiry time? TL; DR如果设置了public并且对象具有不确定的到期时间,则设置max-age是否有任何优点/缺点?

Cache-Control: public means that the resource is publicly available, and thus may be put in cache available to several users (such as a corporate Internet proxy). Cache-Control: public意味着资源是公共可用的,因此可以将其放置在可供多个用户使用的缓存中(例如公司Internet代理)。 It has nothing to do with how long a resource may be cached. 它与资源可以缓存多长时间无关。 See RFC2616 . 参见RFC2616

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

相关问题 缓存控制:在公共或最大年龄之前? - Cache-Control: before public or max-age? http请求中的cache-control:max-age = 0和If-Not-Modified - cache-control:max-age=0 and If-Not-Modified in http request http请求中的“ cache-control:max-age = 0” - `cache-control: max-age=0` in http request HTTP Cache-Control 标头 max-age 与 max-age,必须重新验证 - HTTP Cache-Control header max-age vs max-age, must-revalidate 缓存控制:public,max-age = LONG_TIME响应在HTTP 301重定向后不起作用 - Cache-Control: public,max-age=LONG_TIME response does not work behind HTTP 301 redirect CloudFront “年龄” header 对“缓存控制:私有; 最大年龄=3600” - CloudFront “age” header effect on “cache-control: private; max-age=3600” 使用`Cache-Control: max-age`时是否必须使用`Age`? - Does `Age` have to be used when using `Cache-Control: max-age`? max-age,no-Cache,必须在Cache-Control Header上重新验证,在此优先? - max-age, no-Cache,must-revalidate on Cache-Control Header, Which takes predence here? Cache-Control: max-age=0 和 no-cache 有什么区别? - What's the difference between Cache-Control: max-age=0 and no-cache? 当您使用 Cache-Control: max-age 和 ETag 时会发生什么? - What happens when you use Cache-Control: max-age with ETags?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM