HTTP 中缓存控制标头的最大值 [英] Max value for cache control header in HTTP

查看:26
本文介绍了HTTP 中缓存控制标头的最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Amazon S3 为我的网站提供静态资产.我想让浏览器尽可能长时间地缓存这些资产.我应该在我的资产中包含哪些元数据标头

I'm using Amazon S3 to serve static assets for my website. I want to have browsers cache these assets for as long as possible. What meta-data headers should I include with my assets

Cache-Control: max-age=???

推荐答案

通常建议将一年作为标准最大值.请参阅 RFC 2616:

Generally one year is advised as a standard max value. See RFC 2616:

要将响应标记为永不过期",源服务器发送一个截止日期从响应时间算起大约一年发送.HTTP/1.1 服务器不应该发送超过一个的过期日期未来一年.

To mark a response as "never expires," an origin server sends an Expires date approximately one year from the time the response is sent. HTTP/1.1 servers SHOULD NOT send Expires dates more than one year in the future.

虽然这适用于较旧的 expires 标准,但在没有任何明确的标准指导的情况下,也适用于 cache-control 也是有意义的.只要您通常需要,并且选择任意更长的值可能会破坏一些用户代理.所以:

Although that applies to the older expires standard, it makes sense to apply to cache-control too in the absence of any explicit standards guidance. It's as long as you should generally need anyway and picking any arbitrarily longer value could break some user-agents. So:

Cache-Control: max-age=31536000

这篇关于HTTP 中缓存控制标头的最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆