我一直在使用最优秀的http://redbot.org工具测试我的站点上的headers是否正确(它在PHP中的自定义代码提供动态内容--希望确保它在可能的情况下被Apache2缓存)
其中一项测试显示:
The If-Modified-Since response is missing required headers
HTTP requires 304 Not Modified responses to have certain headers, if they are also present in a normal (e.g., 200 OK response).
This response is missing the following headers: last-modified.
This can affect cache operation; because the headers are missing, caches might remove them from their cached copies...。因此,共振不包括最后修改的标题。然而,代码确实试图发送它。进一步研究,Apache似乎使用了一个HTTP头白名单,它将允许304响应.
if (r->status == HTTP_NOT_MODIFIED) {
apr_table_do((int (*)(void *, const char *, const char *)) form_header_field,
(void *) &h, r->headers_out,
"Connection",
"Keep-Alive",
"ETag",
"Content-Location",
"Expires",
"Cache-Control",
"Vary",
"Warning",
"WWW-Authenticate",
"Proxy-Authenticate",
"Set-Cookie",
"Set-Cookie2",
NULL);
}
else {
send_all_header_fields(&h, r);
}这可以在Apache 2.2.22源代码的模块/http/http_filters.c第1281行中找到。
……“最后一次修改”不在名单上。
?
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html似乎没有指定是否应该包括最后修改的内容。(它确实说Etag应该是--这是Apaches中允许的)
如果它有用,这就是测试用例:http://redbot.org/?uri=http%3A%2F%2Fwww.geograph.org.uk%2Fhelp%2Fsitemap --我的代码确实包含了最后修改的头--只是redbot永远得不到它(或者任何自定义的X-)。(标题)。
发布于 2012-02-06 23:39:23
你说得对。RED实现了来自HTTPbis https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-p4-conditional-18#section-4.1的需求。
通常情况下,HTTPbis需求是向后兼容的,与RFC2616兼容(也就是说,它们现在不制造符合2616不符合的实现),但是这个改变已经过去了--我们将打开一个问题来解决这个问题,同时我将修改REDs的需求。
发布于 2012-02-06 14:24:26
不,Last-Modified不是必需的,正如你引用RFC 2616的话。我发现了https://github.com/mnot/redbot/issues/61问题,在这个问题中,他们实现了对所需标头的检查。但是,他们在问题中说,只需要“日期”,但执行情况不同(我认为是错误的)。
https://webmasters.stackexchange.com/questions/25520
复制相似问题