Expires vs max-age,如果两者都在HTTP响应中声明,哪一个优先? [英] Expires vs max-age, which one takes priority if both are declared in a HTTP response?

查看:151
本文介绍了Expires vs max-age,如果两者都在HTTP响应中声明,哪一个优先?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果HTTP响应同时返回Expires和max-age指示使用哪一个?

If a HTTP response that returns both Expires and max-age indications which one is used?

Cache-Control: max-age=3600
Expires: Tue, 15 May 2008 07:19:00 GMT

考虑到每个人都指的是不同的时间点。

Considering that each one refers to a different point in time.

推荐答案

看到这个答案:

三个.htaccess到期规则之间的差异


如果响应包含Expires标头和max-age指令,
max-age指令覆盖Expires标头,即使
Expires标头更具限制性。对于给定的响应,此规则允许源服务器

HTTP / 1.1(或更高版本)缓存提供比HTTP / 1.0缓存更长的到期时间。如果某些HTTP / 1.0缓存不正确地计算年龄或
到期时间,这可能是
有用,可能是由于时钟不同步。

If a response includes both an Expires header and a max-age directive, the max-age directive overrides the Expires header, even if the Expires header is more restrictive. This rule allows an origin server to provide, for a given response, a longer expiration time to an HTTP/1.1 (or later) cache than to an HTTP/1.0 cache. This might be useful if certain HTTP/1.0 caches improperly calculate ages or expiration times, perhaps due to desynchronized clocks.

这篇关于Expires vs max-age,如果两者都在HTTP响应中声明,哪一个优先?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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