<?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.3.10 -->
<?rfc toc="yes"?>
<?rfc tocindent="yes"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>
<?rfc strict="yes"?>
<?rfc compact="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc-ext html-pretty-print="prettyprint https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"?>
<rfc xmlns:x="http://purl.org/net/xml2rfc/ext"
     category="std"
     docName="draft-ietf-httpbis-cache-header-05"
     ipr="trust200902"
     submissionType="IETF">
   <x:feedback template="mailto:ietf-http-wg@w3.org?subject={docname},%20%22{section}%22\&amp;amp;body=%3c{ref}%3e:"/>
   <front>
      <title abbrev="Cache-Status Header">The Cache-Status HTTP Response Header Field</title>
      <author fullname="Mark Nottingham" initials="M." surname="Nottingham">
         <organization>Fastly</organization>
         <address>
            <postal>
               <street>made in</street>
               <city>Prahran</city>
               <region>VIC</region>
               <country>Australia</country>
            </postal>
            <email>mnot@mnot.net</email>
            <uri>https://www.mnot.net/</uri>
         </address>
      </author>
      <date year="2020" month="August" day="11"/>
      <area>Applications and Real-Time</area>
      <workgroup>HTTP</workgroup>
      <keyword>Internet-Draft</keyword>
      <abstract>
         <t>To aid debugging, HTTP caches often append header fields to a response explaining how they handled the request. This specification codifies that practice and updates it to align with HTTP’s current caching model.</t>
      </abstract>
      <note title="Note to Readers">
         <t>
            <spanx>RFC EDITOR: please remove this section before publication</spanx>
         </t>
         <t>Discussion of this draft takes place on the HTTP working group mailing list (ietf-http-wg@w3.org), which is archived at <eref target="https://lists.w3.org/Archives/Public/ietf-http-wg/">https://lists.w3.org/Archives/Public/ietf-http-wg/</eref>.</t>
         <t>Working Group information can be found at <eref target="https://httpwg.org/">https://httpwg.org/</eref>; source code and issues list for this draft can be found at <eref target="https://github.com/httpwg/http-extensions/labels/cache-header">https://github.com/httpwg/http-extensions/labels/cache-header</eref>.</t>
      </note>
   </front>
   <middle>
      <section anchor="introduction" title="Introduction">
         <t>To aid debugging, HTTP caches often append header fields to a response explaining how they handled the request. Unfortunately, the semantics of these headers are often unclear, and both the semantics and syntax used vary greatly between implementations.</t>
         <t>This specification defines a single, new HTTP response header field, “Cache-Status” for this purpose.</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>
            <t>This document uses ABNF as defined in <xref target="RFC5234"/>, along with the “%s” extension for case sensitivity defined in <xref target="RFC7405"/>.</t>
         </section>
      </section>
      <section anchor="field" title="The Cache-Status HTTP Response Header Field">
         <t>The Cache-Status HTTP response header indicates caches’ handling of the request corresponding to the response it occurs within.</t>
         <t>Its value is a List <xref target="I-D.ietf-httpbis-header-structure"/>:</t>
         <figure>
            <artwork type="abnf">
Cache-Status   = sf-list
</artwork>
         </figure>
         <t>Each member of the list represents a cache that has handled the request. The first member of the list represents the cache closest to the origin server, and the last member of the list represents the cache closest to the client (possibly including the user agent’s cache itself, if it chooses to append a value).</t>
         <t>Caches determine when it is appropriate to add the Cache-Status header field to a response. Some might add it to all responses, whereas others might only do so when specifically configured to, or when the request contains a header that activates a debugging mode.</t>
         <t>When adding a value to the Cache-Status header field, caches SHOULD preserve the existing contents of the header field, to allow debugging of the entire chain of caches handling the request.</t>
         <t>Each list member identifies the cache that inserted that value, and MUST be a String or Token. Depending on the deployment, this might be a product or service name (e.g., ExampleCache or “Example CDN”), a hostname (“cache-3.example.com”), and IP address, or a generated string.</t>
         <t>Each member of the list can also have parameters that describe that cache’s handling of the request. While all of these parameters are OPTIONAL, caches are encouraged to provide as much information as possible.</t>
         <t>This specification defines these parameters:</t>
         <figure>
            <artwork type="abnf">
hit          = sf-boolean
fwd          = sf-token
fwd-status   = sf-integer
ttl          = sf-integer
stored       = sf-boolean
collapsed    = sf-boolean
key          = sf-string
detail       = sf-token / sf-string
</artwork>
         </figure>
         <section anchor="the-hit-parameter" title="The hit parameter">
            <t>“hit”, when true, indicates that the request was satisfied by the cache; i.e., it did not go forward, and the response was obtained from the cache. A response that originally was produced by the origin but was modified by the cache (for example, a 304 or 206 status code) is still considered a hit.</t>
            <t>“hit” and “fwd” are exclusive; only one of them should appear on each list member.</t>
         </section>
         <section anchor="the-fwd-parameter" title="The fwd parameter">
            <t>“fwd” indicates that the request went forward towards the origin, and why.</t>
            <t>The following values are defined to explain why the request went forward:</t>
            <t>
               <list style="symbols">
                  <t>uri-miss - The cache did not contain any responses that matched the request URI</t>
                  <t>vary-miss - The cache contained a response that matched the request URI, but could not select a response based upon this request’s headers and stored Vary headers.</t>
                  <t>miss - The cache did not contain any responses that could be used to satisfy this request (to be used when an implementation cannot distinguish between uri-miss and vary-miss)</t>
                  <t>stale - The cache was able to select a response for the request, but it was stale</t>
                  <t>request - The cache was able to select a fresh response for the request, but client request headers (e.g., Cache-Control request directives) did not allow its use</t>
                  <t>bypass - The cache was configured to not handle this request</t>
               </list>
            </t>
         </section>
         <section anchor="the-fwd-status-parameter" title="The fwd-status parameter">
            <t>“fwd-status” indicates what status code the next hop server returned in response to the request. Only meaningful when “fwd” is present; if “fwd-status” is not present but “fwd” is, it defaults to the status code sent in the response.</t>
            <t>This parameter is useful to distinguish cases when the next hop server sends a 304 Not Modified response to a conditional request, or a 206 Partial Response because of a range request.</t>
         </section>
         <section anchor="the-ttl-parameter" title="The ttl parameter">
            <t>“ttl” indicates the response’s remaining freshness lifetime as calculated by the cache, as an integer number of seconds, measured when the response is sent by the cache. This includes freshness assigned by the cache; e.g., through heuristics, local configuration, or other factors. May be negative, to indicate staleness.</t>
         </section>
         <section anchor="the-stored-parameter" title="The stored parameter">
            <t>“stored” indicates whether the cache stored the response; a true value indicates that it did. Only meaningful when fwd is present.</t>
         </section>
         <section anchor="the-collapsed-parameter" title="The collapsed parameter">
            <t>“collapsed” indicates whether this request was collapsed together with one or more other forward requests; if true, the response was successfully reused; if not, a new request had to be made. If not present, the request was not collapsed with others. Only meaningful when fwd is present.</t>
         </section>
         <section anchor="the-key-parameter" title="The key parameter">
            <t>“key” conveys a representation of the cache key used for the response. Note that this may be implementation-specific.</t>
         </section>
         <section anchor="the-detail-parameter" title="The detail parameter">
            <t>“detail” allows implementations to convey additional information not captured in other parameters; for example, implementation-specific states, or other caching-related metrics.</t>
            <t>For example:</t>
            <figure>
               <artwork type="example">
Cache-Status: ExampleCache; hit; detail=MEMORY
</artwork>
            </figure>
            <t>The semantics of a detail parameter are always specific to the cache that sent it; even if a member of details from another cache shares the same name, it might not mean the same thing.</t>
            <t>This parameter is intentionally limited. If an implementation needs to convey additional information, they are encouraged to register extension parameters (see <xref target="register"/>) or define another header field.</t>
         </section>
      </section>
      <section anchor="examples" title="Examples">
         <t>The most minimal cache hit:</t>
         <figure>
            <artwork type="example">
Cache-Status: ExampleCache; hit
</artwork>
         </figure>
         <t>… but a polite cache will give some more information, e.g.:</t>
         <figure>
            <artwork type="example">
Cache-Status: ExampleCache; hit; ttl=376
</artwork>
         </figure>
         <t>A stale hit just has negative freshness:</t>
         <figure>
            <artwork type="example">
Cache-Status: ExampleCache; hit; ttl=-412
</artwork>
         </figure>
         <t>Whereas a complete miss is:</t>
         <figure>
            <artwork type="example">
Cache-Status: ExampleCache; fwd=uri-miss
</artwork>
         </figure>
         <t>A miss that successfully validated on the back-end server:</t>
         <figure>
            <artwork type="example">
Cache-Status: ExampleCache; fwd=stale; fwd-status=304
</artwork>
         </figure>
         <t>A miss that was collapsed with another request:</t>
         <figure>
            <artwork type="example">
Cache-Status: ExampleCache; fwd=uri-miss; collapsed
</artwork>
         </figure>
         <t>A miss that the cache attempted to collapse, but couldn’t:</t>
         <figure>
            <artwork type="example">
Cache-Status: ExampleCache; fwd=uri-miss; collapsed=?0
</artwork>
         </figure>
         <t>Going through two layers of caching, both of which were hits, and the second collapsed with other requests:</t>
         <figure>
            <artwork type="example">
Cache-Status: OriginCache; hit; ttl=1100; collapsed,
              "CDN Company Here"; hit; ttl=545
</artwork>
         </figure>
      </section>
      <section anchor="register" title="Defining New Proxy-Status Parameters">
         <t>New Cache-Status Parameters can be defined by registering them in the HTTP Cache-Status Parameters registry.</t>
         <t>Registration requests are reviewed and approved by a Designated Expert, as per <xref target="RFC8126" x:fmt="," x:sec="4.5"/>. A specification document is appreciated, but not required.</t>
         <t>The Expert(s) should consider the following factors when evaluating requests:</t>
         <t>
            <list style="symbols">
               <t>Community feedback</t>
               <t>If the value is sufficiently well-defined</t>
               <t>Generic parameters are preferred over vendor-specific, application-specific or deployment-specific values. If a generic value cannot be agreed upon in the community, the parameter’s name should be correspondingly specific (e.g., with a prefix that identifies the vendor, application or deployment).</t>
            </list>
         </t>
         <t>Registration requests should use the following template:</t>
         <t>
            <list style="symbols">
               <t>Name: [a name for the Cache-Status Parameter that matches key]</t>
               <t>Description: [a description of the parameter semantics and value]</t>
               <t>Reference: [to a specification defining this parameter]</t>
            </list>
         </t>
         <t>See the registry at <eref target="https://iana.org/assignments/http-cache-status">https://iana.org/assignments/http-cache-status</eref> for details on where to send registration requests.</t>
      </section>
      <section anchor="iana-considerations" title="IANA Considerations">
         <t>Upon publication, please create the HTTP Cache-Status Parameters registry at <eref target="https://iana.org/assignments/http-cache-status">https://iana.org/assignments/http-cache-status</eref> and populate it with the types defined in <xref target="field"/>; see <xref target="register"/> for its associated procedures.</t>
      </section>
      <section anchor="security-considerations" title="Security Considerations">
         <t>Attackers can use the information in Cache-Status to probe the behaviour of the cache (and other components), and infer the activity of those using the cache. The Cache-Status header field may not create these risks on its own, but can assist attackers in exploiting them.</t>
         <t>For example, knowing if a cache has stored a response can help an attacker execute a timing attack on sensitive data. Exposing the cache key can help an attacker understand modifications to the cache key, which may assist cache poisoning attacks. See <xref target="ENTANGLE"/> for details.</t>
         <t>The underlying risks can be mitigated with a variety of techniques (e.g., use of encryption and authentication; avoiding the inclusion of attacker-controlled data in the cache key), depending on their exact nature.</t>
         <t>To avoid assisting such attacks, the Cache-Status header field can be omitted, only sent when the client is authorized to receive it, or only send sensitive information (e.g., the key parameter) when the client is authorized.</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="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>
         <reference anchor="RFC5234">
            <front>
               <title>Augmented BNF for Syntax Specifications: ABNF</title>
               <author fullname="D. Crocker"
                       initials="D."
                       role="editor"
                       surname="Crocker"/>
               <author fullname="P. Overell" initials="P." surname="Overell"/>
               <date month="January" year="2008"/>
            </front>
            <seriesInfo name="STD" value="68"/>
            <seriesInfo name="RFC" value="5234"/>
            <seriesInfo name="DOI" value="10.17487/RFC5234"/>
         </reference>
         <reference anchor="RFC7405">
            <front>
               <title>Case-Sensitive String Support in ABNF</title>
               <author fullname="P. Kyzivat" initials="P." surname="Kyzivat"/>
               <date month="December" year="2014"/>
            </front>
            <seriesInfo name="RFC" value="7405"/>
            <seriesInfo name="DOI" value="10.17487/RFC7405"/>
         </reference>
         <reference anchor="I-D.ietf-httpbis-header-structure">
            <front>
               <title>Structured Field Values for HTTP</title>
               <author fullname="Mark Nottingham" initials="M" surname="Nottingham"/>
               <author fullname="Poul-Henning Kamp" initials="P" surname="Kamp"/>
               <date day="3" month="June" year="2020"/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-header-structure-19"/>
         </reference>
         <reference anchor="RFC8126">
            <front>
               <title>Guidelines for Writing an IANA Considerations Section in RFCs</title>
               <author fullname="M. Cotton" initials="M." surname="Cotton"/>
               <author fullname="B. Leiba" initials="B." surname="Leiba"/>
               <author fullname="T. Narten" initials="T." surname="Narten"/>
               <date month="June" year="2017"/>
            </front>
            <seriesInfo name="BCP" value="26"/>
            <seriesInfo name="RFC" value="8126"/>
            <seriesInfo name="DOI" value="10.17487/RFC8126"/>
         </reference>
      </references>
      <references title="Informative References">
         <reference anchor="ENTANGLE"
                    target="https://i.blackhat.com/USA-20/Wednesday/us-20-Kettle-Web-Cache-Entanglement-Novel-Pathways-To-Poisoning-wp.pdf">
            <front>
               <title>Web Cache Entanglement: Novel Pathways to Poisoning</title>
               <author fullname="James Kettle" initials="J." surname="Kettle">
                  <organization>PortSwigger</organization>
               </author>
               <date year="n.d."/>
            </front>
         </reference>
      </references>
   </back>
</rfc>
