当前位置: 代码迷 >> Web前端 >> Http Response Cacheability 懂得
  详细解决方案

Http Response Cacheability 懂得

热度:529   发布时间:2013-12-15 22:17:18.0
Http Response Cacheability 理解

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,

?

如果response没有显示设置cache-control, (1)caching系统( 浏览器)可能总是缓存成功的response到缓存中, 这样随后的请求可能直接返回缓存里面的数据当缓存没过期或者向服务器验证缓存没过期.(2)如果response头中没有cache validator (Last-Modified/ETag),也没有Expire,我们不期望缓存response.

?

总体的意思应该是,如果response头部有cache validator (Last-Modified/ETag)或者Expire信息, caching系统应该要缓存到本地. 如果既没有cache?validator?也没有validator?信息,caching系统不应该缓存response到本地

?

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.

Note that section?14.8?normally prevents a shared cache from saving and returning a response to a previous request if that request included an Authorization header.

A response received with a status code of 200, 203, 206, 300, 301 or 410 MAY be stored by a cache and used in reply to a subsequent request, subject to the expiration mechanism, unless a cache-control directive prohibits caching. However, a cache that does not support the Range and Content-Range headers MUST NOT cache 206 (Partial Content) responses.

A response received with any other status code (e.g. status codes 302 and 307) MUST NOT be returned in a reply to a subsequent request unless there are cache-control directives or another header(s) that explicitly allow it. For example, these include the following: an Expires header (section?14.21); a "max-age", "s-maxage", "must- revalidate", "proxy-revalidate", "public" or "private" cache-control directive (section?14.9).

  相关解决方案