expires、max-age 和共享 max-age 之间有什么区别?
I have never used HTTP Caching.
I found those caching options on Symfony documentation page.
I just wanted to know what's the difference between expires
, max-age
, and s-maxage
headers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不久之后:HTTP/1.0 代理可以理解
Expires
,而Cache-control: max-age=
是在 HTTP/1.1 中引入的。s-maxage
与 max-age 类似,但它适用于代理而不是客户端。Shortly:
Expires
is understand by HTTP/1.0 agents, whereasCache-control: max-age=
was introduced in HTTP/1.1.s-maxage
is similar to max-age but it applies to proxies instead of clients.缓存控制:
在 HTTP/1.1 中引入并取代以前用于定义响应缓存策略的标头(例如 Expires)。所有现代浏览器都支持缓存控制,因此这就是我们所需要的。
过期:
虽然 Cache-Control 标头打开客户端缓存并设置资源的 max-age,但 Expires 标头用于指定资源不再有效的特定时间点。
最大年龄:
在客户端和代理上用于内容过期
s-maxage:
仅由代理用于内容过期
Cache-Control:
Was introduced in HTTP/1.1 and supersedes previous headers (e.g. Expires) used to define response caching policies. All modern browsers support Cache-Control, hence that is all we will need.
Expires:
While the Cache-Control header turns on client-side caching and sets the max-age of a resource, the Expires header is used to specify a specific point in time the resource is no longer valid.
max-age:
Used on both client and proxy for content expiration
s-maxage:
Used only by the proxy for content expiration