问题描述
服务器将这些标头发送给客户端:
I have these headers being sent to the client by the server:
Cache-Control:private
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html
Date:Sun, 27 Nov 2011 11:10:38 GMT
ETag:"12341234"
Set-Cookie:connect.sid=e1u...7o; path=/; expires=Sun, 27 Nov 2011 11:40:38 GMT; httpOnly
Transfer-Encoding:chunked
last-modified:Sat, 26 Nov 2011 21:42:45 GMT
我希望客户端验证文件在服务器上没有更改,如果它有304",则发送200".
I want the client to validate that the file hasn't changed on the server and send a "200" if it has otherwise a "304".
Firefox 发送:
Firefox sends:
if-modified-since: Sat, 26 Nov 2011 21:42:45 GMT
if-none-match: "12341234"
为什么刷新页面时 chrome 不发送相同的内容?我正在关注.Net 运行的行为:
Why isn't the chrome sending the same on a refresh of the page? I'm after the behavior that .Net has running:
context.Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate)
推荐答案
根据我的经验,您需要的不仅仅是Private"Cache-Control 标头.您需要Max-Age"或Expires"来强制 Chrome 使用服务器重新验证内容.
In my experience you need more than just the "Private" Cache-Control header. You need either "Max-Age" or "Expires" to force Chrome to revalidate content with the server.
请记住,重新验证只会在这些时间值过去后开始,因此可能需要将它们设置为一个较小的值.
Remember that revalidation will only start after these time values have elapsed, so they may need to be set to a small value.
这篇关于Chrome 浏览器未将 if-modified-since 标头发送到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!