问题描述
HTTP响应标头中 Expires:0
和 Expires:-1
之间有什么区别? 定义无效的日期格式,尤其包括值0 已过期。但是,某些服务器(例如www.google.de)回复 Expires:-1
。
What is the difference between Expires: 0
and Expires: -1
in the HTTP response header? RFC 2616 defines invalid date formats, especially including the value "0" as already expired. However, some servers (e.g. www.google.de) reply with Expires: -1
.
是否有使用 -1
而不是 0
的优势还是某些损坏的HTTP客户端甚至需要它?
Is there an advantage over using -1
over 0
or is this even required for some broken HTTP clients?
推荐答案
问题在于Internet Explorer(尤其是旧版本)处理的Expires标头的无效程度。
IE使用布局引擎和用于处理HTTP请求的API。您可能知道可以在HTTP标头中指定过期
The problem is in how invalid Expires header processed by Internet Explorer (especially older versions).IE uses Trident layout engine and WinINET API to process HTTP requests. As you may know Expires could be specified in HTTP header
Expires: 0
或元标记
<meta http-equiv="Expires" content="0">
在第二种情况下,Expires成为响应内容的一部分(不是标题内容),因此它将成为:
In second case, Expires became part of the response content (not header content), so it will be processed by Trident and then propagated to WinINET:
换句话说过期:0
并不总是导致资源过期,因此应该避免并且过期:[某个有效日期在应该使用过去的
。
In other words Expires: 0
not always leads to immediate resource expiration, therefore should be avoided and Expires: [some valid date in the past]
should be used instead.
这篇关于HTTP Expires头值“0”。和“-1”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!