跳到主要内容

5.2.1. Request Cache-Control 指令 (Request Cache-Control Directives)

本节定义 client 可以在 HTTP request 中使用的 cache directive.

5.2.1.1. max-age

Argument: delta-seconds

"max-age" request directive 表示 client 不愿意接受 age 大于指定秒数的 response. 除非同时存在 max-stale request directive, 否则 client 不愿意接受 stale response.

该 directive 使用 argument syntax 的 token 形式: 例如, max-age=5, 而不是 max-age="5". sender SHOULD NOT 生成 quoted-string 形式.

5.2.1.2. max-stale

Argument: delta-seconds

"max-stale" request directive 表示 client 愿意接受已超过其 freshness lifetime 的 response. 如果 max-stale 被赋予一个 value, 则 client 愿意接受超过 freshness lifetime 不多于指定秒数的 response. 如果 max-stale 未被赋值, 则 client 愿意接受任意 age 的 stale response.

该 directive 使用 argument syntax 的 token 形式: 例如, max-stale=10, 而不是 max-stale="10". sender SHOULD NOT 生成 quoted-string 形式.

5.2.1.3. min-fresh

Argument: delta-seconds

"min-fresh" request directive 表示 client 愿意接受 freshness lifetime 不小于其 current age 加上指定秒数的 response. 也就是说, client 希望得到一个至少在指定秒数内仍保持 fresh 的 response.

该 directive 使用 argument syntax 的 token 形式: 例如, min-fresh=20, 而不是 min-fresh="20". sender SHOULD NOT 生成 quoted-string 形式.

5.2.1.4. no-cache

"no-cache" request directive 表示 cache MUST NOT 在未于 origin server 成功 validation 的情况下, 使用已存储 response 来满足 request.

5.2.1.5. no-store

"no-store" request directive 表示 cache MUST NOT 存储此 request 或其任何 response 的任何部分. 该 directive 同时适用于 private cache 和 shared cache. 在此上下文中, "MUST NOT store" 表示 cache MUST NOT 有意将 information 存储在 non-volatile storage 中, 并且 MUST 尽最大努力在转发后尽快从 volatile storage 中移除该 information.

该 directive 不是确保 privacy 的可靠或充分机制. 特别是, malicious 或 compromised cache 可能不识别或不遵守该 directive, communication network 也可能容易被 eavesdropping.

注意, 如果包含该 directive 的 request 由 cache 满足, no-store request directive 不适用于已经存储的 response.

5.2.1.6. no-transform

"no-transform" request directive 表示 intermediary (无论是否实现 cache) MUST NOT transform payload, 如 Section 5.7.2 of [RFC7230] 所定义.

5.2.1.7. only-if-cached

"only-if-cached" request directive 表示 client 只希望获得已存储 response. 如果 cache 收到此 directive, 它 SHOULD 要么使用与 request 其他 constraint 一致的已存储 response 进行响应, 要么以 504 (Gateway Timeout) status code 响应. 如果一组 cache 作为具有良好内部 connectivity 的 unified system 运行, member cache MAY 在该 cache group 内转发此类 request.