<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version 1.7.29 (Ruby 3.2.2) -->
<?rfc tocindent="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"
     consensus="true"
     docName="draft-ietf-httpbis-cache-groups-07"
     ipr="trust200902"
     sortRefs="true"
     symRefs="true"
     tocInclude="true">
   <x:feedback template="mailto:ietf-http-wg@w3.org?subject={docname},%20%22{section}%22\&amp;amp;body=%3c{ref}%3e:"/>
   <front>
      <title>HTTP Cache Groups</title>
      <author fullname="Mark Nottingham" initials="M." surname="Nottingham">
         <address>
            <postal>
               <postalLine>Prahran</postalLine>
               <postalLine>Australia</postalLine>
            </postal>
            <email>mnot@mnot.net</email>
            <uri>https://www.mnot.net/</uri>
         </address>
      </author>
      <date year="2025" month="May" day="16"/>
      <area>Web and Internet Transport</area>
      <workgroup>HTTP</workgroup>
      <keyword>HTTP, Caching, Invalidation</keyword>
      <abstract><?line 48?>
         <t>This specification introduces a means of describing the relationships between stored responses in HTTP caches, "grouping" them by associating a stored response with one or more strings.</t>
      </abstract>
      <note removeInRFC="true" title="About This Document">
         <t>Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-ietf-httpbis-cache-groups/"/>.</t>
         <t>Discussion of this document takes place on the HTTP Working Group mailing list (<eref target="mailto:ietf-http-wg@w3.org"/>), which is archived at <eref target="https://lists.w3.org/Archives/Public/ietf-http-wg/"/>. Working Group information can be found at <eref target="https://httpwg.org/"/>.</t>
         <t>Source for this draft and an issue tracker can be found at <eref target="https://github.com/httpwg/http-extensions/labels/cache-groups"/>.</t>
      </note>
   </front>
   <middle><?line 52?>
      <section anchor="introduction">
         <name>Introduction</name>
         <t>HTTP caching <xref target="HTTP-CACHING"/> operates at the granularity of a single resource; the freshness of one stored response does not affect that of others. This granularity can make caching more efficient -- for example, when a page is composed of many assets that have different requirements for caching.</t>
         <t>However, there are also cases where the relationship between stored responses could be used to improve cache efficiency.</t>
         <t>For example, it is often necessary to invalidate a set of related resources. This might be because a state-changing request has side effects on other resources, or it might be purely for administrative convenience (e.g., "invalidate this part of the site"). Grouping responses together provides a dedicated way to express these relationships, instead of relying on things like URL structure.</t>
         <t>In addition to sharing invalidation events, the relationships indicated by grouping can also be used by caches to optimise their operation; for example, it could be used to inform the operation of cache eviction algorithms.</t>
         <t>
            <xref target="cache-groups"/> introduces a means of describing the relationships between stored responses in HTTP caches, by associating those responses with one or more groups that reflect those relationships. It also describes how caches can use that information to apply invalidation events to members of a group.</t>
         <t>
            <xref target="cache-group-invalidation"/> introduces one new source of such events: a HTTP response header field that allows a state-changing response to trigger a group invalidation.</t>
         <t>These mechanisms operate within a single cache, across the stored responses associated with a single origin server (see <xref target="identify"/>). They do not address the issues of synchronising state between multiple caches (e.g., in a hierarchy or mesh), nor do they facilitate association of stored responses from disparate origins.</t>
         <section anchor="notational-conventions">
            <name>Notational Conventions</name>
            <t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>", "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" 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>
            <?line -18?>
            <t>This specification uses the following terminology from <xref target="STRUCTURED-FIELDS"/>: List, String, Parameter.</t>
         </section>
      </section>
      <section anchor="cache-groups">
         <name>The Cache-Groups Response Header Field</name>
         <t>The Cache-Groups HTTP Response Header is a List of Strings (Sections <xref section="3.1" sectionFormat="bare" target="STRUCTURED-FIELDS"/> and <xref section="3.3.1" sectionFormat="bare" target="STRUCTURED-FIELDS"/> of <xref target="STRUCTURED-FIELDS"/>). Each member of the list is a value that identifies a group that the response belongs to. These strings are opaque -- while they might have some meaning to the server that creates them, the cache does not have any insight into their structure or content (beyond uniquely identifying a group).</t>
         <figure>
            <sourcecode type="http-message">
HTTP/1.1 200 OK
Content-Type: application/javascript
Cache-Control: max-age=3600
Cache-Groups: "scripts"
</sourcecode>
         </figure>
         <t>The ordering of members is not significant. Unrecognised Parameters are to be ignored.</t>
         <t>Implementations <bcp14>MUST</bcp14> support at least 32 groups in a field value, with up to at least 32 characters in each member. Note that generic limitations on HTTP field lengths may constrain the size of this field value in practice.</t>
         <section anchor="identify">
            <name>Identifying Grouped Responses</name>
            <t>Two responses stored in the same cache are considered to belong to the same group when all of the following conditions are met:</t>
            <t>
               <list style="numbers">
                  <t>They both contain a Cache-Groups response header field that contains the same String (in any position in the List), when compared character-by-character (case sensitive).</t>
                  <t>They both share the same URI origin (per <xref section="4.3.1" sectionFormat="of" target="HTTP"/>).</t>
               </list>
            </t>
         </section>
         <section anchor="cache-behaviour">
            <name>Cache Behaviour</name>
            <section anchor="invalidation">
               <name>Invalidation</name>
               <t>A cache that invalidates a stored response <bcp14>MAY</bcp14> invalidate any stored responses that share groups (per <xref target="identify"/>) with that response. Note that further grouped invalidations are not triggered by a grouped invalidation; i.e., this mechanism does not "cascade."</t>
               <t>Cache extensions can explicitly strengthen the requirement above. For example, a targeted cache control header field <xref target="TARGETED"/> might specify that caches processing it are required to invalidate such responses.</t>
            </section>
         </section>
      </section>
      <section anchor="cache-group-invalidation">
         <name>The Cache-Group-Invalidation Response Header Field</name>
         <t>The Cache-Group-Invalidation response header field is a List of Strings (Sections <xref section="3.1" sectionFormat="bare" target="STRUCTURED-FIELDS"/> and <xref section="3.3.1" sectionFormat="bare" target="STRUCTURED-FIELDS"/> of <xref target="STRUCTURED-FIELDS"/>). Each member of the list is a value that identifies a group that the response invalidates, per <xref target="invalidation"/>.</t>
         <t>For example, following a POST request that has side effects on two cache groups, the corresponding response could indicate that stored responses associated with either or both of those groups should be invalidated with:</t>
         <figure>
            <sourcecode type="http-message">
HTTP/1.1 200 OK
Content-Type: text/html
Cache-Group-Invalidation: "eurovision-results", "australia"
</sourcecode>
         </figure>
         <t>The Cache-Group-Invalidation header field <bcp14>MUST</bcp14> be ignored on responses to requests that have a safe method (e.g., GET; see <xref section="9.2.1" sectionFormat="of" target="HTTP"/>).</t>
         <t>A cache that receives a Cache-Group-Invalidation header field on a response to an unsafe request <bcp14>MAY</bcp14> invalidate any stored responses that share groups (per <xref target="identify"/>) with any of the listed groups.</t>
         <t>Cache extensions can explicitly strengthen the requirement above. For example, a targeted cache control header field <xref target="TARGETED"/> might specify that caches processing it are required to respect the Cache-Group-Invalidation signal.</t>
         <t>The ordering of members is not significant. Unrecognised Parameters are to be ignored.</t>
         <t>Implementations <bcp14>MUST</bcp14> support at least 32 groups in a field value, with up to at least 32 characters in each member. Note that generic limitations on HTTP field lengths may constrain the size of this field value in practice.</t>
      </section>
      <section anchor="iana-considerations">
         <name>IANA Considerations</name>
         <t>IANA should perform the following tasks:</t>
         <section anchor="http-field-names">
            <name>HTTP Field Names</name>
            <t>Enter the following into the Hypertext Transfer Protocol (HTTP) Field Name Registry:</t>
            <t>
               <list style="symbols">
                  <t>Field Name: Cache-Groups</t>
                  <t>Status: permanent</t>
                  <t>Reference: RFC nnnn</t>
                  <t>Comments:</t>
                  <t>Field Name: Cache-Group-Invalidation</t>
                  <t>Status: permanent</t>
                  <t>Reference: RFC nnnn</t>
                  <t>Comments:</t>
               </list>
            </t>
         </section>
      </section>
      <section anchor="security-considerations">
         <name>Security Considerations</name>
         <t>This mechanism allows resources that share an origin to invalidate each other. Because of this, origins that represent multiple parties (sometimes referred to as "shared hosting") might allow one party to group its resources with those of others, or to send signals which have side effects upon them.</t>
         <t>Shared hosts that wish to mitigate these risks can control access to the header fields defined in this specification.</t>
      </section>
   </middle>
   <back>
      <references anchor="sec-combined-references" title="References">
         <references anchor="sec-normative-references" title="Normative References">
            <reference anchor="HTTP">
               <front>
                  <title>HTTP Semantics</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="2022"/>
               </front>
               <seriesInfo name="STD" value="97"/>
               <seriesInfo name="RFC" value="9110"/>
               <seriesInfo name="DOI" value="10.17487/RFC9110"/>
            </reference>
            <reference anchor="HTTP-CACHING">
               <front>
                  <title>HTTP 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="2022"/>
               </front>
               <seriesInfo name="STD" value="98"/>
               <seriesInfo name="RFC" value="9111"/>
               <seriesInfo name="DOI" value="10.17487/RFC9111"/>
            </reference>
            <reference anchor="STRUCTURED-FIELDS">
               <front>
                  <title>Structured Field Values for HTTP</title>
                  <author fullname="M. Nottingham" initials="M." surname="Nottingham"/>
                  <author fullname="P-H. Kamp" surname="P-H. Kamp"/>
                  <date month="September" year="2024"/>
               </front>
               <seriesInfo name="RFC" value="9651"/>
               <seriesInfo name="DOI" value="10.17487/RFC9651"/>
            </reference>
            <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>
         </references>
         <references anchor="sec-informative-references" title="Informative References">
            <reference anchor="TARGETED">
               <front>
                  <title>Targeted HTTP Cache Control</title>
                  <author fullname="S. Ludin" initials="S." surname="Ludin"/>
                  <author fullname="M. Nottingham" initials="M." surname="Nottingham"/>
                  <author fullname="Y. Wu" initials="Y." surname="Wu"/>
                  <date month="June" year="2022"/>
               </front>
               <seriesInfo name="RFC" value="9213"/>
               <seriesInfo name="DOI" value="10.17487/RFC9213"/>
            </reference>
         </references>
      </references>
      <?line 179?>
      <section anchor="acknowledgements">
         <name>Acknowledgements</name>
         <t>Thanks to Stephen Ludin for his review and suggestions.</t>
      </section>
   </back>
</rfc>
