<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.2.2 -->
<?rfc toc="yes"?>
<rfc xmlns:x="http://purl.org/net/xml2rfc/ext"
     category="std"
     number="8246"
     ipr="trust200902"
     submissionType="IETF">
  <link rel="convertedFrom" href="https://datatracker.ietf.org/doc/draft-ietf-httpbis-immutable/"/>
    <front>
      <title>HTTP Immutable Responses</title>
      <author fullname="Patrick McManus" initials="P." surname="McManus">
         <organization>Mozilla</organization>
         <address>
            <email>mcmanus@ducksong.com</email>
         </address>
      </author>
      <date month="September" year="2017"/>
      <area>Applications and Real-Time</area>
      <workgroup>HTTP</workgroup>
      <abstract>
         <t>The immutable HTTP response Cache-Control extension allows servers to identify resources that will not be updated during their freshness lifetime. This ensures that a client never needs to revalidate a cached fresh resource to be certain it has not been modified.</t>
      </abstract>
   </front>
   <middle>
      <section anchor="introduction" title="Introduction">
         <t>HTTP’s freshness lifetime mechanism <xref target="RFC7234"/> allows a client to safely reuse a stored response to satisfy future requests for a specified period of time. However, it is still possible that the resource will be modified during that period.</t>
         <t>For instance, a front-page newspaper photo with a freshness lifetime of one hour would mean that no user would see a cached photo more than one hour old. However, the photo could be updated at any time, resulting in different users seeing different photos depending on the contents of their caches for up to one hour. This is compliant with the caching mechanism defined in <xref target="RFC7234"/>.</t>
         <t>Users that need to confirm there have been no updates to their cached responses typically use the reload (or refresh) mechanism in their user agents. This in turn generates a conditional request <xref target="RFC7232"/>, and either a new representation or, if unmodified, a 304 (Not Modified) response <xref target="RFC7232"/> is returned. A user agent that understands HTML and fetches its dependent sub-resources might issue hundreds of conditional requests to refresh all portions of a common page <xref target="REQPERPAGE"/>.</t>
         <t>However, some content providers never create more than one variant of a sub-resource, because they use “versioned” URLs. When these resources need an update, they are simply published under a new URL, typically embedding an identifier unique to that version of the resource in the path, and references to the sub-resource are updated with the new path information.</t>
         <t>For example, <spanx style="verb">https://www.example.com/101016/main.css</spanx> might be updated and republished as <spanx style="verb">https://www.example.com/102026/main.css</spanx>, with any links that reference it being changed at the same time. This design pattern allows a very large freshness lifetime to be used for the sub-resource without guessing when it will be updated in the future.</t>
         <t>Unfortunately, the user agent does not know when this versioned URL design pattern is used. As a result, user-driven refreshes still translate into wasted conditional requests for each sub-resource as each will return 304 responses.</t>
         <t>The immutable HTTP response Cache-Control extension allows servers to identify responses that will not be updated during their freshness lifetimes.</t>
         <t>This effectively informs clients that any conditional request for that response can be safely skipped without worrying that it has been updated.</t>
         <section anchor="notational-conventions" title="Notational Conventions">
            <t>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 <xref target="RFC2119"/>
               <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.</t>
         </section>
      </section>
      <section anchor="the-immutable-cache-control-extension"
               title="The Immutable Cache-Control Extension">
         <t>When present in an HTTP response, the immutable Cache-Control extension indicates that the origin server will not update the representation of that resource during the freshness lifetime of the response.</t>
         <t>Clients SHOULD NOT issue a conditional request during the response’s freshness lifetime (e.g., upon a reload) unless explicitly overridden by the user (e.g., a force reload).</t>
         <t>The immutable extension only applies during the freshness lifetime of the stored response. Stale responses SHOULD be revalidated as they normally would be in the absence of the immutable extension.</t>
         <t>The immutable extension takes no arguments. If any arguments are present, they have no meaning and MUST be ignored. Multiple instances of the immutable extension are equivalent to one instance. The presence of an immutable Cache-Control extension in a request has no effect.</t>
         <section anchor="about-intermediaries" title="About Intermediaries">
            <t>An immutable response has the same semantic meaning when received by proxy clients as it does when received by user-agent-based clients. Therefore, proxies SHOULD skip conditionally revalidating fresh responses containing the immutable extension unless there is a signal from the client that a validation is necessary (e.g., a no-cache Cache-Control request directive defined in <xref target="RFC7234" x:fmt="of" x:sec="5.2.1.4"/>).</t>
            <t>A proxy that uses the immutable extension to bypass a conditional revalidation can choose whether to reply with a 304 or 200 response to its requesting client based on the request headers the proxy received.</t>
         </section>
         <section anchor="example" title="Example">
            <figure>
               <artwork type="example">
Cache-Control: max-age=31536000, immutable
</artwork>
            </figure>
         </section>
      </section>
      <section anchor="security-considerations" title="Security Considerations">
         <t>The immutable mechanism acts as form of soft pinning and, as with all pinning mechanisms, creates a vector for amplification of cache corruption incidents. These incidents include cache-poisoning attacks. Three mechanisms are suggested for mitigation of this risk:</t>
         <t>
            <list style="symbols">
               <t>Clients SHOULD ignore the immutable extension from resources that are not part of an authenticated context such as HTTPS. Authenticated resources are less vulnerable to cache poisoning.</t>
               <t>User agents often provide two different refresh mechanisms: reload and some form of force-reload. The latter is used to rectify interrupted loads and other corruption. These reloads, typically indicated through no-cache request attributes, SHOULD ignore the immutable extension as well.</t>
               <t>Clients SHOULD ignore the immutable extension for resources that do not provide a strong indication that the stored response size is the correct response size such as responses delimited by connection close.</t>
            </list>
         </t>
      </section>
      <section anchor="iana-considerations" title="IANA Considerations">
         <t>The immutable extension has been registered in the “Hypertext Transfer Protocol (HTTP) Cache Directive Registry” per the guidelines described in <xref target="RFC7234" x:fmt="of" x:sec="7.1"/>.</t>
         <t>
            <list style="symbols">
               <t>Cache Directive: immutable</t>
               <t>Reference: RFC 8246</t>
            </list>
         </t>
      </section>
   </middle>
   <back>
      <references title="Normative References">
         <reference anchor="RFC2119">
            <front>
               <title>Key words for use in RFCs to Indicate Requirement Levels</title>
               <author fullname="S. Bradner" initials="S." surname="Bradner"/>
               <date month="March" year="1997"/>
            </front>
            <seriesInfo name="BCP" value="14"/>
            <seriesInfo name="RFC" value="2119"/>
            <seriesInfo name="DOI" value="10.17487/RFC2119"/>
         </reference>
         <reference anchor="RFC7232">
            <front>
               <title>Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests</title>
               <author fullname="R. Fielding"
                       initials="R."
                       role="editor"
                       surname="Fielding"/>
               <author fullname="J. Reschke"
                       initials="J."
                       role="editor"
                       surname="Reschke"/>
               <date month="June" year="2014"/>
            </front>
            <seriesInfo name="RFC" value="7232"/>
            <seriesInfo name="DOI" value="10.17487/RFC7232"/>
         </reference>
         <reference anchor="RFC7234">
            <front>
               <title>Hypertext Transfer Protocol (HTTP/1.1): Caching</title>
               <author fullname="R. Fielding"
                       initials="R."
                       role="editor"
                       surname="Fielding"/>
               <author fullname="M. Nottingham"
                       initials="M."
                       role="editor"
                       surname="Nottingham"/>
               <author fullname="J. Reschke"
                       initials="J."
                       role="editor"
                       surname="Reschke"/>
               <date month="June" year="2014"/>
            </front>
            <seriesInfo name="RFC" value="7234"/>
            <seriesInfo name="DOI" value="10.17487/RFC7234"/>
         </reference>
         <reference anchor="RFC8174">
            <front>
               <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
               <author fullname="B. Leiba" initials="B." surname="Leiba"/>
               <date month="May" year="2017"/>
            </front>
            <seriesInfo name="BCP" value="14"/>
            <seriesInfo name="RFC" value="8174"/>
            <seriesInfo name="DOI" value="10.17487/RFC8174"/>
         </reference>
      </references>
      <references title="Informative References">
         <reference anchor="REQPERPAGE"
                    target="http://httparchive.org/interesting.php#reqTotal">
            <front>
               <title>Total Requests per Page</title>
               <author>
                  <organization>HTTP Archive</organization>
               </author>
               <date/>
            </front>
         </reference>
      </references>
      <section anchor="acknowledgments" numbered="false" title="Acknowledgments">
         <t>Thank you to Ben Maurer for partnership in developing and testing this idea. Thank you to Amos Jeffries for help with proxy interactions and to Mark Nottingham for help with the documentation.</t>
      </section>
   </back>
</rfc>
