跳到主要内容

5. Header Field 定义 (Header Field Definitions)

本节定义与 caching 相关的 HTTP header field 的语法和语义.

5.1. Age

"Age" header field 传达 sender 对 response 在 origin server 生成或成功 validation 以来经过时间量的估计. Age value 按 Section 4.2.3 中指定的方式计算.

Age = delta-seconds

Age field value 是非负整数, 表示以秒为单位的时间 (见 Section 1.2.1).

Age header field 的存在意味着该 response 并不是 origin server 为此 request 生成或 validation 的. 但是, 缺少 Age header field 并不意味着已经联系过 origin, 因为 response 可能来自不实现 Age 的 HTTP/1.0 cache.

5.2. Cache-Control

"Cache-Control" header field 用于为 request/response chain 上的 cache 指定 directive. 此类 cache directive 是单向的, 因为 request 中存在某个 directive 并不意味着 response 中也要给出同一 directive.

cache MUST 遵守本节定义的 Cache-Control directive requirement. 关于如何处理其他地方定义的 Cache-Control directive, 见 Section 5.2.3.

Note: 某些 HTTP/1.0 cache 可能不实现 Cache-Control.

proxy 无论是否实现 cache, 都 MUST 在 forwarded message 中传递 cache directive, 不管这些 directive 对该 application 的意义如何, 因为 directive 可能适用于 request/response chain 上的所有 recipient. 无法将 directive 定向到某个特定 cache.

cache directive 由 token 标识, 比较时不区分大小写, 并具有 optional argument, 该 argument 可以同时使用 token 和 quoted-string 语法. 对于下文定义且带 argument 的 directive, recipient ought to 接受两种形式, 即使生成时要求使用特定形式.

Cache-Control = 1#cache-directive

cache-directive = token [ "=" ( token / quoted-string ) ]

对于下文定义的 cache directive, 除非另有说明, 否则不定义也不允许 argument.