rfc-9213

Targeted HTTP Cache Control

S. Ludin, M. Nottingham, Y. Wu
date2022-06 streamIETF areawit wghttpbis statusPROPOSED STANDARD pages8 canonicalhttps://www.rfc-editor.org/rfc/rfc9213 doi10.17487/RFC9213
This specification defines a convention for HTTP response header fields that allow cache directives to be targeted at specific caches or classes of caches. It also defines one such header field, the CDN-Cache-Control response header field, which is targeted at content delivery network (CDN) caches.

Extracted elements (20)

design-rationale §1

Existing HTTP Cache-Control is undifferentiated across cache tiers — while s-maxage targets shared caches, not all directives (e.g., stale-while-revalidate) have equivalent targeting. Ad hoc implementations exist but have low interoperability, motivating a standard framework for targeted cache control.

http, security

design-rationale §3.1

The example 'CDN-Cache-Control: none' (where 'none' is not a registered directive) demonstrates a pattern for preventing all non-CDN caches from storing a response while still allowing CDN storage — using an unrecognized directive to avoid an empty header value that would be ignored.

http

design-rationale §2.3

This specification does not mandate specific requirements to mitigate the age-penalty interaction with HTTP freshness, but definitions of targeted fields can impose such requirements. Deployment techniques include removing the Age header, updating Date, or updating Expires.

http

interoperability-note §2.3

A targeted cache with longer freshness lifetimes (e.g., CDN-Cache-Control: max-age=3600 vs Cache-Control: max-age=600) may serve responses that appear stale to downstream caches, negatively impacting their cache efficiency. The Age header field propagates this staleness.

http

interoperability-note §2.1

Using a Cache-Control parser rather than a Structured Fields parser for targeted fields can introduce interoperability issues due to differences in error handling, even though the syntax is often similar.

http

normative-requirement §2.4 MUST NOT

By convention, targeted fields use the suffix '-Cache-Control' (e.g., 'ExampleCDN-Cache-Control'), but this suffix MUST NOT be used on its own to identify targeted fields — it is only a convention.

http, registry

normative-requirement §2.2 MUST

Caches that use a targeted field MUST implement the semantics of the following cache directives: max-age, must-revalidate, no-store, no-cache, and private. They SHOULD also implement other directives they support in Cache-Control.

http

normative-requirement §3 MAY

CDN caches using CDN-Cache-Control will typically forward this header so that downstream CDN caches can use it, but MAY remove it when configured to do so (e.g., when it is known not to be used downstream).

http

normative-requirement §2.1 MUST

If a targeted field in a given response is empty or a parsing error is encountered, that field MUST be ignored by the cache — it behaves as if the field were not present, falling back to other cache-control mechanisms.

http

normative-requirement §2.1 MUST NOT

Implementations MUST NOT generate directive values that violate inferred type constraints. In particular, string values whose first character is not alphabetic or '*' MUST be generated as Strings to avoid being misinterpreted as other types.

http

normative-requirement §2.1 SHOULD NOT

Implementations SHOULD NOT consume cache directive values that violate inferred type constraints. For example, coercing a max-age with a decimal value into an integer could cause interoperability issues.

http

normative-requirement §2.2 MUST NOT

Targeted fields that are not on a cache's target list MUST NOT change that cache's behavior and MUST be passed through to downstream recipients.

http

normative-requirement §2.2 MUST

When a cache receives a response with one or more header fields on its target list, the cache MUST select the first (in target-list order) field with a valid, non-empty value and use it to determine caching policy, and it MUST ignore Cache-Control and Expires in that response unless no valid, non-empty targeted value is available.

http

protocol-element §2.2

A cache implementing this specification maintains a target list: an ordered list of targeted field names used for caching policy, with order reflecting priority from most applicable to least. The target list may be fixed, user-configurable, or generated per request.

http

protocol-element §2

A Targeted Cache-Control Header Field is an HTTP response header field with the same semantics as Cache-Control but with a distinct field name indicating its target cache class. For example, CDN-Cache-Control targets CDN caches.

http

protocol-element §3

CDN-Cache-Control is a targeted field allowing origin servers to control CDN cache behavior independently from other caches. It applies to caches in a distributed network operating on behalf of an origin server (CDNs).

http

protocol-element §2.4

New targeted fields are defined by requesting registration in the IANA 'Hypertext Transfer Protocol (HTTP) Field Name Registry'. The Comments field should clearly identify the class of caches the field targets.

http, registry

registry §4

IANA registered 'CDN-Cache-Control' as a permanent entry in the 'Hypertext Transfer Protocol (HTTP) Field Name Registry' (RFC 9213), with the comment 'Cache directives targeted at content delivery networks'.

http, registry

security-consideration §5

Carrying multiple caching policies on a single response can cause confusion about how that response will be cached in different systems, potentially resulting in unintentional reuse of responses containing sensitive information. Implementers must exercise care when deploying targeted cache-control headers alongside Cache-Control.

http, security, privacy

wire-format §2.1

Targeted fields are Dictionary Structured Fields (RFC 8941 Section 3.2). Each dictionary member is an HTTP cache response directive. Directives with no value map to Boolean; quoted-string values map to String; token values map to Token, Integer, or Decimal depending on content.

http, json