5.2.2.2. no-cache(response)

2 阅读1分钟

5.2.2.2. no-cache(response)

rfc 7234 5.2.2.2. no-cache

不带值

  The "no-cache" response directive indicates that the response MUST
   NOT be used to satisfy a subsequent request without successful
   validation on the origin server.  This allows an origin server to
   prevent a cache from using it to satisfy a request without contacting
   it, even by caches that have been configured to send stale responses.

request(no-cache)-response不能(MUST NOT)用来reuse,除非对其进行验证之后。例如:

Cache-Control: no-cache

带值

If the no-cache response directive specifies one or more field-names,
   then a cache MAY use the response to satisfy a subsequent request,
   subject to any other restrictions on caching.  However, any header
   fields in the response that have the field-name(s) listed MUST NOT be
   sent in the response to a subsequent request without successful
   revalidation with the origin server. 

我怎么感觉这句话是这个意思,假设此时cache中有缓存:

request(no-cache:"X-User-Points")-response

根据rfc定义:

  1. cache可以reuse除了“X-User-Points” header以外的部分,将其发给client;或者
  2. cache可以为缓存发起条件验证,验证以后将最新的request(no-cache:"X-User-Points")-response返回给client;注意,如果验证了以后,
  3. 就不用排除“X-User-Points” header了