<?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.9 -->
<?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-00"
     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 Header">The Cache HTTP Response Header</title>
      <author fullname="Mark Nottingham" initials="M." surname="Nottingham">
         <organization>Fastly</organization>
         <address>
            <email>mnot@mnot.net</email>
            <uri>https://www.mnot.net/</uri>
         </address>
      </author>
      <date year="2019" month="January" day="27"/>
      <area>Applications and Real-Time</area>
      <workgroup>HTTP Working Group</workgroup>
      <keyword>Internet-Draft</keyword>
      <abstract>
         <t>To aid debugging, HTTP caches often append headers to a response detailing how they handled the request. This specification codifies that practice and updates it for 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 headers to a response detailing how they handled the request.</t>
         <t>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” for this purpose.</t>
         <t>For example:</t>
         <figure>
            <artwork type="example">
Cache: HIT_FRESH; node="reverse-proxy.example.com:80";
                  key="https://example.com/foo|Accept-Encoding:gzip",
       HIT_STALE; node="FooCDN parent"; fresh=-45; age=200; latency=3,
       MISS; node="FooCDN edge"; fresh=-45; age=200; latency=98
</artwork>
         </figure>
         <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="the-cache-http-response-header"
               title="The Cache HTTP Response Header">
         <t>The Cache HTTP response header indicates the handling of the request corresponding to the response it occurs within by caches along the path.</t>
         <t>Its value is a Parameterised List <xref target="I-D.ietf-httpbis-header-structure"/>:</t>
         <figure>
            <artwork type="abnf">
Cache   = sh-param-list
</artwork>
         </figure>
         <t>Each member of the parameterised list represents a cache that has handled the request.</t>
         <t>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 user agent (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 header field to a response. Some might decide to 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 header field, caches SHOULD preserve the existing contents of the header, to allow debugging of the entire chain of caches handling the request.</t>
         <t>Identifiers in the parameterised list members are expected to be cache-actions:</t>
         <figure>
            <artwork type="abnf">
cache-action   = %s"HIT_FRESH"
               / %s"HIT_STALE"
               / %s"HIT_REFRESH_MODIFIED"
               / %s"HIT_REFRESH_NOT_MODIFIED"
               / %s"HIT_REFRESH_STALE"
               / %s"MISS"
               / %s"MISS_CLIENT"
               / %s"BYPASS"
               / %s"ERROR"
</artwork>
         </figure>
         <t>The semantics of cache-actions are:</t>
         <t>
            <list style="symbols">
               <t>HIT_FRESH - The cache used a fresh stored response to satisfy the request without going forward</t>
               <t>HIT_STALE - The cache used a stale stored response to satisfy the request without going forward</t>
               <t>HIT_REFRESH_MODIFIED - The cache had a stale stored response, went forward to validate it, and used the new response to satisfy the request</t>
               <t>HIT_REFRESH_NOT_MODIFIED - The cache had a stale stored response, went forward to validate it, and used the stored response to satisfy the request</t>
               <t>HIT_REFRESH_STALE - The cache had a stale stored response, went forward to validate it, and encountered a problem, so the stored response was used to satisfy the request</t>
               <t>MISS - The cache did not have a stored response, so the request was forwarded</t>
               <t>MISS_CLIENT - The client included request directives (e.g., Pragma, Cache-Control) that prevented the cache from returning a response, so the request was forwarded</t>
               <t>BYPASS - The cache was configured to forward the request without attempting to use a stored response</t>
               <t>ERROR - The cache was unable to use a stored response or obtain one by going forward</t>
            </list>
         </t>
         <t>Caches SHOULD use the most specific cache-action to a given response, but are not required to use all cache-actions. Future updates to this specification can add additional cache-actions.</t>
         <t>Each member of the Cache header can also have any (or all, or none) of the following parameters:</t>
         <figure>
            <artwork type="abnf">
node           = sh-string
fresh          = sh-integer
age            = sh-integer
cacheable      = sh-boolean
key            = sh-string
latency        = sh-integer
cl_nm          = sh-boolean
</artwork>
         </figure>
         <t>Their semantics are:</t>
         <t>
            <list style="symbols">
               <t>“node” - a string identifying for the cache node. MAY be a hostname, IP address, or alias.</t>
               <t>“fresh” - an integer indicating the cache’s estimation of the freshness lifetime (<xref target="RFC7234" x:fmt="," x:sec="4.2.1"/>) of this response in seconds, including any locally applied configuration. MAY be negative.</t>
               <t>“age” - an integer indicating the cache’s estimation of the age (<xref target="RFC7234" x:fmt="," x:sec="4.2.3"/>) of this response in seconds. MUST be 0 or greater.</t>
               <t>“cacheable” - a boolean indicating whether the cache can store this response, according to <xref target="RFC7234" x:fmt="," x:sec="3"/> and any locally applied configuration.</t>
               <t>“key” - a string representing the key that the cache has associated with this response. This might include the request URL, request headers, and other values.</t>
               <t>“latency” - an integer indicating the amount of time in milliseconds between the receipt of a complete set of request headers and sending the complete set of response headers of this response, from the viewpoint of the cache. Note that this may not include buffering time in transport protocols and similar delays.</t>
               <t>“cl_nm” - a boolean indicating whether the response to the client had a 304 Not Modified status code.</t>
            </list>
         </t>
         <t>While all of these parameters are OPTIONAL, caches are encouraged to use the ‘node’ parameter to identify themselves.</t>
      </section>
      <section anchor="security-considerations" title="Security Considerations">
         <t>Information about a cache’s content can be used to infer the activity of those using it. Generally, access to sensitive information in a cache is limited to those who are authorised to access that information (using a variety of techniques), so this does not represent an attack vector in the general sense.</t>
         <t>However, if the Cache header is exposed to parties who are not authorised to obtain the response it occurs within, it could expose information about that data.</t>
         <t>For example, if an attacker were able to obtain the Cache header from a response containing sensitive information and access were limited to one person (or limited set of people), they could determine whether that information had been accessed before. This is similar to the information exposed by various timing attacks, but is arguably more reliable, since the cache is directly reporting its state.</t>
         <t>Mitigations include use of encryption (e.g., TLS <xref target="RFC8446"/>)) to protect the response, and careful controls over access to response headers (as are present in the Web platform). When in doubt, the Cache header field can be omitted.</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 Headers for HTTP</title>
               <author fullname="Mark Nottingham" initials="M" surname="Nottingham"/>
               <author fullname="Poul-Henning Kamp" initials="P" surname="Kamp"/>
               <date day="1" month="December" year="2018"/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-header-structure-09"/>
         </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>
      </references>
      <references title="Informative References">
         <reference anchor="RFC8446">
            <front>
               <title>The Transport Layer Security (TLS) Protocol Version 1.3</title>
               <author fullname="E. Rescorla" initials="E." surname="Rescorla"/>
               <date month="August" year="2018"/>
            </front>
            <seriesInfo name="RFC" value="8446"/>
            <seriesInfo name="DOI" value="10.17487/RFC8446"/>
         </reference>
      </references>
   </back>
</rfc>
