?
HTTP header仅有cache validator没有cache(Expire/Cache Control)信息, 页面会被cache吗?
?
1. HTTP是通过Header Expire (HTTP1.0) 和 Cache Control (HTTP 1.0) 控制一个页面是否要被缓存.
?
在页面没有过期之前,所有的请求都会走缓存. 如果头部同时Expire?和Cache Control, 浏览器会用Cache Control覆盖Expire.
?
2. 如果Response没有任何缓存的信息(Expire和Cache Control)., 仅有cache validator(ast-modified/ETag)页面会走cache吗
?
下面的一段内容是从HTTP协议摘取过来的
?
13.4?Response Cacheability
Unless specifically constrained by a cache-control (section?14.9) directive, a caching system MAY always store a successful response (see section?13.8) as a cache entry, MAY return it without validation if it is fresh, and MAY return it after successful validation. If there is neither a cache validator nor an explicit expiration time associated with a response, we do not expect it to be cached, but certain caches MAY violate this expectation (for example, when little or no network connectivity is available). A client can usually detect that such a response was taken from a cache by comparing the Date header to the current time.
Note: some HTTP/1.0 caches are known to violate this expectation
without providing any Warning.
However, in some cases it might be inappropriate for a cache to retain an entity, or to return it in response to a subsequent request. This might be because absolute semantic transparency is deemed necessary by the service author, or because of security or privacy considerations. Certain cache-control directives are therefore provided so that the server can indicate that certain resource entities, or portions thereof, are not to be cached regardless of other considerations.
?
从红色字体中我们可以了解
1. 如果response头部既没有 cache validator (last-modified/ETag) 也没有 expiration time(Expires/Cache control), HTTP是不推荐缓存页面的.?
2. 如果response头部既有 cache validator?(last-modified/ETag),也有expiration time(Expires/Cache control),?页面也会被缓存住.?
3. 那如果response头部仅有?cache validator(last-modified/ETag) 了, 从文字上理解, 似乎页面要被缓存住的? ?通过在chrome和firefox上测试(请看附件).后面的请求的的确是走缓存的,?但是cache会存在多少时间了(没有地方显式设置时间呀)???
?
3. 思考
如果cache validator (last-modified/ETag) 脱离 cache?(Expire/Cache Control) 设置单独存在, 是个异常情况, 皮之不存,毛将焉附.
chrome/firefox在这种情况,还是会缓存页面的, 随后的请求也会走cache的.但是cache有效时间多少了?
?
?
?
Referrences:
- http://hmh1985.iteye.com/admin/blogs/1988105
- http://stackoverflow.com/questions/5860216/no-expires-header-sent-content-cached-how-long-until-browser-makes-conditional
- https://developers.google.com/speed/docs/best-practices/caching
-
http://developer.yahoo.com/performance/rules.html?(Add an Expires or a Cache-Control Header)
?
?