RFC 8246
HTTP Immutable Responses
RFC 8246: HTTP Immutable Responses π¦
Okay bestie, the title block tea β: this is a Standards Track doc from September 2017, ISSN 2070-1721, written by Patrick McManus from Mozilla π. It's an Internet Standards Track document, so this is the real deal. The title block doesn't list anything it obsoletes or updates, so it's standing on its own β¨.
Abstract β¨
The big idea is the immutable response Cache-Control extension. It lets servers flag resources that won't change during their freshness lifetime. So a client never has to revalidate a cached fresh resource just to be sure it hasn't been modified. Main character energy π
Status of This Memo π
This is an Internet Standards Track document.
This doc is a product of the Internet Engineering Task Force (IETF) π It represents the consensus of the IETF community, got public review, and was approved for publication by the Internet Engineering Steering Group (IESG). For more on Internet Standards, check Section 2 of RFC 7841.
For the current status, any errata, and how to send feedback, go to https://www.rfc-editor.org/info/rfc8246 π
Copyright Notice βοΈ
Copyright (c) 2017 IETF Trust and the persons identified as the document authors. All rights reserved.
This doc is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) as in effect on the date of publication. Please read those carefully, because they spell out your rights and restrictions for this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions, and they're provided without warranty as described in the Simplified BSD License.
Table of Contents ποΈ
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1. Notational Conventions . . . . . . . . . . . . . . . . . 3
2. The Immutable Cache-Control Extension . . . . . . . . . . . . 3
2.1. About Intermediaries . . . . . . . . . . . . . . . . . . 4
2.2. Example . . . . . . . . . . . . . . . . . . . . . . . . . 4
3. Security Considerations . . . . . . . . . . . . . . . . . . . 4
4. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 5
5. References . . . . . . . . . . . . . . . . . . . . . . . . . 5
5.1. Normative References . . . . . . . . . . . . . . . . . . 5
5.2. Informative References . . . . . . . . . . . . . . . . . 5
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 6
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 6
1. Introduction πΈ
Okay so HTTP's freshness lifetime mechanism [RFC7234] lets a client safely reuse a stored response to answer future requests for a set amount of time. The catch is that the resource can still change during that window π
Picture a front-page newspaper photo with a one-hour freshness lifetime. No user sees a cached photo more than an hour old. But the photo could get updated at any moment, so different users might see different photos for up to an hour, depending on what's in their caches. Totally legal under the caching rules in [RFC7234], just a little chaotic π
When users need to be sure nothing changed, they usually hit the reload (or refresh) button. That sends a conditional request [RFC7232], and the server either returns a new representation or, if nothing changed, a 304 (Not Modified) response [RFC7232]. A user agent that understands HTML and fetches its sub-resources can fire off hundreds of conditional requests just to refresh one page [REQPERPAGE] π
Some content providers avoid all that by never making more than one variant of a sub-resource. They use "versioned" URLs instead. When something needs an update, it gets published under a brand-new URL, usually with an identifier for that version baked into the path. Then every reference gets switched to the new path π
For example, https://www.example.com/101016/main.css might get updated and republished as https://www.example.com/102026/main.css, and any links pointing at it change at the same time.
This pattern means you can use a really big freshness lifetime for the sub-resource without guessing when it'll change next. Iconic π
Unfortunately, the user agent has no idea when a site is using the versioned URL pattern. So user-driven refreshes still produce wasted conditional requests for every sub-resource, and each one just comes back as a 304 π₯²
The immutable HTTP response Cache-Control extension fixes this. It lets servers flag responses that won't be updated during their freshness lifetimes β¨
Basically, it tells clients that any conditional request for that response can be skipped safely, with no worries about it having changed π¦
1.1. Notational Conventions π
Here's the vocab: the key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here. Lowercase is just vibes π
2. The Immutable Cache-Control Extension π
When it shows up in an HTTP response, the immutable Cache-Control extension tells you the origin server won't update that resource's representation during the response's freshness lifetime π§
Clients SHOULD NOT issue a conditional request during the response's freshness lifetime (e.g., upon a reload), unless the user explicitly overrides that (e.g., with a force reload) π ββοΈ
The immutable extension only applies during the freshness lifetime of the stored response. Stale responses SHOULD be revalidated the way they normally would be without the immutable extension β°
The immutable extension takes no arguments. If any arguments do show up, they have no meaning and MUST be ignored. Multiple instances of the extension count as just one. And if an immutable Cache-Control extension appears in a request, it does absolutely nothing π«
2.1. About Intermediaries π§
An immutable response means the same thing to proxy clients as it does to user-agent-based clients. So proxies SHOULD skip conditionally revalidating fresh responses that have the immutable extension, unless the client sends a signal that validation is needed (e.g., a no-cache Cache-Control request directive, defined in Section 5.2.1.4 of [RFC7234]) π
A proxy that uses the immutable extension to skip a conditional revalidation can choose whether to answer its client with a 304 or a 200 response, based on the request headers it received π
2.2. Example π
Cache-Control: max-age=31536000, immutable
3. Security Considerations π¨
Okay, serious moment, please pay attention π€ The immutable mechanism acts as a form of soft pinning. And like every pinning mechanism, it creates a vector for amplifying cache corruption incidents, including cache-poisoning attacks. That's a big deal. Three mitigations are suggested for this risk:
- Clients SHOULD ignore the immutable extension from resources that aren't part of an authenticated context, such as HTTPS. Authenticated resources are much less vulnerable to cache poisoning π
- User agents often offer two refresh mechanisms: reload, and some form of force-reload. The force-reload is what fixes interrupted loads and other corruption. These reloads, which are typically triggered by no-cache request attributes, SHOULD ignore the immutable extension as well π οΈ
- Clients SHOULD ignore the immutable extension for resources that don't give a strong indication that the stored response size is the correct response size, such as responses delimited by connection close π§―
4. IANA Considerations π
The immutable extension has been registered in the "Hypertext Transfer Protocol (HTTP) Cache Directive Registry", following the guidelines in Section 7.1 of [RFC7234] ποΈ
- Cache Directive:
immutable - Reference:
RFC 8246
5. References π
5.1. Normative References
- [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997,
https://www.rfc-editor.org/info/rfc2119. - [RFC7232] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests", RFC 7232, DOI 10.17487/RFC7232, June 2014,
https://www.rfc-editor.org/info/rfc7232. - [RFC7234] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Caching", RFC 7234, DOI 10.17487/RFC7234, June 2014,
https://www.rfc-editor.org/info/rfc7234. - [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017,
https://www.rfc-editor.org/info/rfc8174.
5.2. Informative References
- [REQPERPAGE] HTTP Archive, "Total Requests per Page",
http://httparchive.org/interesting.php#reqTotal.
Acknowledgments π«Ά
Huge thanks to Ben Maurer for partnering on developing and testing this idea π Thanks to Amos Jeffries for help with proxy interactions, and to Mark Nottingham for help with the documentation π
Author's Address π
Patrick McManus Mozilla
Email: mcmanus@ducksong.com
π¦ where this page comes from
- ietf: rfc8246 2017-09
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms