rfc 7234中Cache entity/key相关定义
rfc 7234 2. Overview of Cache Operation
// 定义 cache entry = cache key + HTTP responses
Each cache entry consists of a cache key and one or more HTTP
responses corresponding to prior requests that used the same key.
The most common form of cache entry is a successful result of a
retrieval request: i.e., a 200 (OK) response to a GET request, which
contains a representation of the resource identified by the request
target (Section 4.3.1 of [RFC7231]). However, it is also possible to
cache permanent redirects, negative results (e.g., 404 (Not Found)),
incomplete results (e.g., 206 (Partial Content)), and responses to
methods other than GET if the method's definition allows such caching
and defines something suitable for use as a cache key.
// 定义primary cache key
The primary cache key consists of the request method and target URI.
However, since HTTP caches in common use today are typically limited
to caching responses to GET, many caches simply decline other methods
and use only the URI as the primary cache key.
// secondary key相关
If a request target is subject to content negotiation, its cache
entry might consist of multiple stored responses, each differentiated
by a secondary key for the values of the original request's selecting
header fields (Section 4.1)
上述节选对于cache key的定义有点模糊,根据rfc 7234其他地方上下文总结如下:
- cache entry = cache key + HTTP responses
- primary key = request method + target URI
- cache key = primary key + secondary key(如果存在)