Safari不发送“If-Modified-Since”和“If-None-Match”头 [英] Safari not sending "If-Modified-Since" and "If-None-Match" headers
问题描述
我正在使用PHP生成动态内容。
I'm generating dynamic content with PHP.
我正在发送以下HTTP标头:
I'm sending the following HTTP-header:
HTTP/1.1 304 Not Modified
Date: Sun, 09 Dec 2012 17:24:41 GMT
Server: Apache
Connection: keep-alive, Keep-Alive
Keep-Alive: timeout=1, max=100
Etag: "237f43b800e655dbe6567f7d32d34c99"
Expires: Sun, 16 Dec 2012 17:24:41 GMT
Cache-Control: max-age=604800
Vary: Accept-Encoding
我稍后检查Etag发送标题('HTTP / 1.1 304未修改')
如果匹配。
这与Chrome和Firefox完美搭配。
但是,Safari(版本6.0.2)不会发送If-Modified-Since和If-None-Match标头。
这是Safari在第二页上发送的Request-Header命中:
I later check for the Etag to send a header('HTTP/1.1 304 Not Modified')
if it matches.
This works perfectly with Chrome and Firefox.
However, Safari (Version 6.0.2) does not send "If-Modified-Since" and "If-None-Match" headers.
This is the Request-Header sent by Safari on the second page hit:
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.17 (KHTML, like Gecko) Version/6.0.2 Safari/536.26.17
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Cache-Control: max-age=0
该页面上链接的所有其他文件都会在适当的时候收到正确的Request-Headers和Safari使用的缓存文件或304.
All other files linked on that page receive the right Request-Headers and Safari used cached files or 304 where appropriate.
为什么不向Safari发送正确的请求-header?
我可以更改什么?
Why doesn't send Safari the correct Request-Header? What could I change?
谢谢!
推荐答案
< h3> If-Modified-Since
If-Modified-Since 警告使用与 Last-Modified
响应头的内容不同的内容:
If-Modified-Since
The notes of If-Modified-Since warn against using something different than the contents of the Last-Modified
response header:
注意:如果客户在If-Modified-Since
标头中使用任意日期而不是从Last-取得的日期修改了
相同请求的标头,客户端应该知道这个
日期是在服务器对时间的理解中解释的。
Note: If a client uses an arbitrary date in the If-Modified-Since header instead of a date taken from the Last-Modified header for the same request, the client should be aware of the fact that this date is interpreted in the server's understanding of time.
您的回复中不包含最后修改,但即使它确实如此,规范中没有任何内容说用户代理必须或者应该发送If-Modified-Since,他们是st MAY。
Your response doesn't contain a Last-Modified, but even if it did, nothing in the spec says that user agents MUST or SHOULD send If-Modified-Since, they just MAY.
关于为什么Safari不发送 If-None-Match 击败我;您的 ETag 看起来有效。
As to why Safari doesn't send an If-None-Match beats me; your ETag looks valid.
再一般来说,规范中没有任何内容表明你必须缓存,只有当你这样做时,你必须遵守< a href =http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 =nofollow>缓存控制。所以它有点不对称关系,你可以强制(透明)缓存来重新检查源服务器,但作为源服务器,你不能强制使用者来缓存。
Again in general nothing in the spec says you MUST cache, just that when you do, you MUST obey Cache-Control. So it's a bit of an asymmetric relation, you can enforce (transparent) caches to recheck with the origin server, but as an origin server, you can't enforce useragents to cache.
Safari只是部分免费软件。所以没什么,如果添加Last-Modified没有帮助。
Safari is only partly free software. So nothing much, if adding a Last-Modified doesn't help.
这篇关于Safari不发送“If-Modified-Since”和“If-None-Match”头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!