跳到主要内容

4.9.4. 基于 Request 改变 Content

4.9.4. 基于 Request 改变 Content (Varying Content Based Upon the Request)

当 resource representation 可基于 request 的某些方面变化时 (例如用于 content negotiation 的 Accept header field), MUST 使用 Vary header field 指示哪些 request header field 会影响所选择的 representation.

例如:

Vary: Accept, Accept-Language

表示 representation 可能基于 AcceptAccept-Language header field 变化.

使用 content negotiation 或其他 request-based variation 的 application MUST 适当地使用 Vary header field. 这确保 cache 能够正确存储和检索不同 representation.

不过, application SHOULD 意识到使用 Vary 可能显著降低 cache efficiency, 因为 cache 需要为 varying header field value 的每种组合存储 response 的独立副本.