<?xml version='1.0' encoding='utf-8'?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" version="3" ipr="trust200902" docName="draft-ietf-httpbis-zstd-window-size-03" number="9659" category="info" consensus="true" submissionType="IETF" updates="8878" tocInclude="true" sortRefs="true" symRefs="true" xml:lang="en" prepTime="2024-09-27T09:13:20" indexInclude="true" scripts="Common,Latin" tocDepth="3">
  <link href="https://datatracker.ietf.org/doc/draft-ietf-httpbis-zstd-window-size-03" rel="prev"/>
  <link href="https://dx.doi.org/10.17487/rfc9659" rel="alternate"/>
  <link href="urn:issn:2070-1721" rel="alternate"/>
  <front>
    <title abbrev="Window Size for zstd">Window Sizing for Zstandard Content Encoding</title>
    <seriesInfo name="RFC" value="9659" stream="IETF"/>
    <author initials="N." surname="Jaju" fullname="Nidhi Jaju" role="editor">
      <organization showOnFrontPage="true">Google</organization>
      <address>
        <postal>
          <street>Shibuya Stream, 3 Chome-21-3 Shibuya</street>
          <region>Shibuya City, Tokyo</region>
          <code>150-0002</code>
          <country>Japan</country>
        </postal>
        <email>nidhijaju@google.com</email>
      </address>
    </author>
    <author initials="W. F." surname="Handte" fullname="W. Felix P. Handte" role="editor">
      <organization showOnFrontPage="true">Meta Platforms, Inc.</organization>
      <address>
        <postal>
          <street>380 W 33rd St</street>
          <city>New York</city>
          <region>NY</region>
          <code>10001</code>
          <country>United States of America</country>
        </postal>
        <email>felixh@meta.com</email>
      </address>
    </author>
    <date month="09" year="2024"/>
    <area>WIT</area>
    <workgroup>httpbis</workgroup>
    <keyword>zstd</keyword>
    <keyword>zstandard</keyword>
    <keyword>compression</keyword>
    <keyword>content encoding</keyword>
    <keyword>content coding</keyword>
    <keyword>application/zstd</keyword>
    <abstract pn="section-abstract">
      <t indent="0" pn="section-abstract-1">Deployments of Zstandard, or "zstd", can use different window
    sizes to limit memory usage during compression and decompression. Some
    browsers and user agents limit window sizes to mitigate memory usage
    concerns, thereby causing interoperability issues. This document updates the
    window size limit in RFC 8878 from a recommendation to a requirement in
    HTTP contexts.</t>
    </abstract>
    <boilerplate>
      <section anchor="status-of-memo" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.1">
        <name slugifiedName="name-status-of-this-memo">Status of This Memo</name>
        <t indent="0" pn="section-boilerplate.1-1">
            This document is not an Internet Standards Track specification; it is
            published for informational purposes.  
        </t>
        <t indent="0" pn="section-boilerplate.1-2">
            This document is a product of the Internet Engineering Task Force
            (IETF).  It represents the consensus of the IETF community.  It has
            received public review and has been approved for publication by the
            Internet Engineering Steering Group (IESG).  Not all documents
            approved by the IESG are candidates for any level of Internet
            Standard; see Section 2 of RFC 7841. 
        </t>
        <t indent="0" pn="section-boilerplate.1-3">
            Information about the current status of this document, any
            errata, and how to provide feedback on it may be obtained at
            <eref target="https://www.rfc-editor.org/info/rfc9659" brackets="none"/>.
        </t>
      </section>
      <section anchor="copyright" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.2">
        <name slugifiedName="name-copyright-notice">Copyright Notice</name>
        <t indent="0" pn="section-boilerplate.2-1">
            Copyright (c) 2024 IETF Trust and the persons identified as the
            document authors. All rights reserved.
        </t>
        <t indent="0" pn="section-boilerplate.2-2">
            This document is subject to BCP 78 and the IETF Trust's Legal
            Provisions Relating to IETF Documents
            (<eref target="https://trustee.ietf.org/license-info" brackets="none"/>) in effect on the date of
            publication of this document. Please review these documents
            carefully, as they describe your rights and restrictions with
            respect to this document. Code Components extracted from this
            document must include Revised BSD License text as described in
            Section 4.e of the Trust Legal Provisions and are provided without
            warranty as described in the Revised BSD License.
        </t>
      </section>
    </boilerplate>
    <toc>
      <section anchor="toc" numbered="false" removeInRFC="false" toc="exclude" pn="section-toc.1">
        <name slugifiedName="name-table-of-contents">Table of Contents</name>
        <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1">
          <li pn="section-toc.1-1.1">
            <t indent="0" keepWithNext="true" pn="section-toc.1-1.1.1"><xref derivedContent="1" format="counter" sectionFormat="of" target="section-1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-introduction">Introduction</xref></t>
          </li>
          <li pn="section-toc.1-1.2">
            <t indent="0" keepWithNext="true" pn="section-toc.1-1.2.1"><xref derivedContent="2" format="counter" sectionFormat="of" target="section-2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-conventions-and-definitions">Conventions and Definitions</xref></t>
          </li>
          <li pn="section-toc.1-1.3">
            <t indent="0" keepWithNext="true" pn="section-toc.1-1.3.1"><xref derivedContent="3" format="counter" sectionFormat="of" target="section-3"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-window-size">Window Size</xref></t>
          </li>
          <li pn="section-toc.1-1.4">
            <t indent="0" pn="section-toc.1-1.4.1"><xref derivedContent="4" format="counter" sectionFormat="of" target="section-4"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-security-considerations">Security Considerations</xref></t>
          </li>
          <li pn="section-toc.1-1.5">
            <t indent="0" pn="section-toc.1-1.5.1"><xref derivedContent="5" format="counter" sectionFormat="of" target="section-5"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-iana-considerations">IANA Considerations</xref></t>
            <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.5.2">
              <li pn="section-toc.1-1.5.2.1">
                <t indent="0" pn="section-toc.1-1.5.2.1.1"><xref derivedContent="5.1" format="counter" sectionFormat="of" target="section-5.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-content-encoding">Content Encoding</xref></t>
              </li>
            </ul>
          </li>
          <li pn="section-toc.1-1.6">
            <t indent="0" pn="section-toc.1-1.6.1"><xref derivedContent="6" format="counter" sectionFormat="of" target="section-6"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-normative-references">Normative References</xref></t>
          </li>
          <li pn="section-toc.1-1.7">
            <t indent="0" pn="section-toc.1-1.7.1"><xref derivedContent="" format="none" sectionFormat="of" target="section-appendix.a"/><xref derivedContent="" format="title" sectionFormat="of" target="name-acknowledgments">Acknowledgments</xref></t>
          </li>
          <li pn="section-toc.1-1.8">
            <t indent="0" pn="section-toc.1-1.8.1"><xref derivedContent="" format="none" sectionFormat="of" target="section-appendix.b"/><xref derivedContent="" format="title" sectionFormat="of" target="name-authors-addresses">Authors' Addresses</xref></t>
          </li>
        </ul>
      </section>
    </toc>
  </front>
  <middle>
    <section anchor="introduction" numbered="true" removeInRFC="false" toc="include" pn="section-1">
      <name slugifiedName="name-introduction">Introduction</name>
      <t indent="0" pn="section-1-1">Zstandard, or "zstd", specified in <xref target="RFC8878" format="default" sectionFormat="of" derivedContent="RFC8878"/>, is a lossless data compression
mechanism similar to gzip. When used with HTTP, the "zstd" content coding
token signals to the decoder that the content is Zstandard-compressed.</t>
      <t indent="0" pn="section-1-2">An important property of Zstandard-compressed content is its Window_Size
(<xref section="3.1.1.1.2" sectionFormat="comma" target="RFC8878" format="default" derivedLink="https://rfc-editor.org/rfc/rfc8878#section-3.1.1.1.2" derivedContent="RFC8878"/>), which describes the maximum distance for
back-references and therefore how much of the content must be kept in memory
during decompression.</t>
      <t indent="0" pn="section-1-3">The minimum Window_Size is 1 KB. The maximum Window_Size is
(1&lt;&lt;41) + 7*(1&lt;&lt;38) bytes, where "&lt;&lt;" denotes a bitwise left shift, which is 3.75 TB. Larger Window_Size values tend
to improve the compression ratio but at the cost of increased memory usage.</t>
      <t indent="0" pn="section-1-4">To protect against unreasonable memory usage, some browsers and user agents
limit the maximum Window_Size they will handle. This causes failures to decode
responses when the content is compressed with a larger Window_Size than the
recipient allows, leading to decreased interoperability.</t>
      <t indent="0" pn="section-1-5"><xref section="3.1.1.1.2" sectionFormat="comma" target="RFC8878" format="default" derivedLink="https://rfc-editor.org/rfc/rfc8878#section-3.1.1.1.2" derivedContent="RFC8878"/> recommends that decoders support a Window_Size
of up to 8 MB, and that encoders not generate frames using a Window_Size larger
than 8 MB. However, it imposes no requirements.</t>
      <t indent="0" pn="section-1-6">This document updates <xref target="RFC8878" format="default" sectionFormat="of" derivedContent="RFC8878"/> to enforce Window_Size limits on the encoder
and decoder for the "zstd" HTTP content coding.</t>
    </section>
    <section anchor="conventions-and-definitions" numbered="true" removeInRFC="false" toc="include" pn="section-2">
      <name slugifiedName="name-conventions-and-definitions">Conventions and Definitions</name>
      <t indent="0" pn="section-2-1">
    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" format="default" sectionFormat="of" derivedContent="RFC2119"/> <xref target="RFC8174" format="default" sectionFormat="of" derivedContent="RFC8174"/> when, and only when, they appear in all capitals, as
    shown here.
</t>
    </section>
    <section anchor="window-size" numbered="true" removeInRFC="false" toc="include" pn="section-3">
      <name slugifiedName="name-window-size">Window Size</name>
      <t indent="0" pn="section-3-1">To ensure interoperability, when using the "zstd" content coding, decoders <bcp14>MUST</bcp14>
support a Window_Size of up to and including 8 MB, and encoders <bcp14>MUST NOT</bcp14>
generate frames requiring a Window_Size larger than 8 MB (see
<xref target="zstd-iana-token" format="default" sectionFormat="of" derivedContent="Section 5.1"/>).</t>
    </section>
    <section anchor="security-considerations" numbered="true" removeInRFC="false" toc="include" pn="section-4">
      <name slugifiedName="name-security-considerations">Security Considerations</name>
      <t indent="0" pn="section-4-1">This document introduces no new security considerations beyond those discussed
in <xref target="RFC8878" format="default" sectionFormat="of" derivedContent="RFC8878"/>.</t>
      <t indent="0" pn="section-4-2">Note that decoders still need to take into account that they can receive
oversized frames that do not follow the window size limit specified in this
document and fail decoding when such invalid frames are received.</t>
    </section>
    <section anchor="iana-considerations" numbered="true" removeInRFC="false" toc="include" pn="section-5">
      <name slugifiedName="name-iana-considerations">IANA Considerations</name>
      <section anchor="zstd-iana-token" numbered="true" removeInRFC="false" toc="include" pn="section-5.1">
        <name slugifiedName="name-content-encoding">Content Encoding</name>
        <t indent="0" pn="section-5.1-1">This document updates the following entry in the "HTTP Content
Coding Registry"
in the <eref target="https://www.iana.org/assignments/http-parameters" brackets="none">"Hypertext Transfer Protocol (HTTP)
Parameters" registry group</eref>:</t>
        <dl indent="3" newline="false" spacing="normal" pn="section-5.1-2">
          <dt pn="section-5.1-2.1">Name:</dt>
          <dd pn="section-5.1-2.2">
            <t indent="0" pn="section-5.1-2.2.1">zstd</t>
          </dd>
          <dt pn="section-5.1-2.3">Description:</dt>
          <dd pn="section-5.1-2.4">
            <t indent="0" pn="section-5.1-2.4.1">A stream of bytes compressed using the Zstandard protocol with a Window_Size
of not more than 8 MB.</t>
          </dd>
          <dt pn="section-5.1-2.5">Reference:</dt>
          <dd pn="section-5.1-2.6">
            <t indent="0" pn="section-5.1-2.6.1">This document and <xref target="RFC8878" format="default" sectionFormat="of" derivedContent="RFC8878"/></t>
          </dd>
        </dl>
      </section>
    </section>
  </middle>
  <back>
    <references anchor="sec-normative-references" pn="section-6">
      <name slugifiedName="name-normative-references">Normative References</name>
      <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119" quoteTitle="true" derivedAnchor="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"/>
          <abstract>
            <t indent="0">In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="2119"/>
        <seriesInfo name="DOI" value="10.17487/RFC2119"/>
      </reference>
      <reference anchor="RFC8174" target="https://www.rfc-editor.org/info/rfc8174" quoteTitle="true" derivedAnchor="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"/>
          <abstract>
            <t indent="0">RFC 2119 specifies common key words that may be used in protocol specifications. This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the defined special meanings.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="8174"/>
        <seriesInfo name="DOI" value="10.17487/RFC8174"/>
      </reference>
      <reference anchor="RFC8878" target="https://www.rfc-editor.org/info/rfc8878" quoteTitle="true" derivedAnchor="RFC8878">
        <front>
          <title>Zstandard Compression and the 'application/zstd' Media Type</title>
          <author fullname="Y. Collet" initials="Y." surname="Collet"/>
          <author fullname="M. Kucherawy" initials="M." role="editor" surname="Kucherawy"/>
          <date month="February" year="2021"/>
          <abstract>
            <t indent="0">Zstandard, or "zstd" (pronounced "zee standard"), is a lossless data compression mechanism. This document describes the mechanism and registers a media type, content encoding, and a structured syntax suffix to be used when transporting zstd-compressed content via MIME.</t>
            <t indent="0">Despite use of the word "standard" as part of Zstandard, readers are advised that this document is not an Internet Standards Track specification; it is being published for informational purposes only.</t>
            <t indent="0">This document replaces and obsoletes RFC 8478.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="8878"/>
        <seriesInfo name="DOI" value="10.17487/RFC8878"/>
      </reference>
    </references>
    <section numbered="false" anchor="acknowledgments" removeInRFC="false" toc="include" pn="section-appendix.a">
      <name slugifiedName="name-acknowledgments">Acknowledgments</name>
      <t indent="0" pn="section-appendix.a-1">Zstandard was developed by <contact fullname="Yann Collet"/>.</t>
      <t indent="0" pn="section-appendix.a-2">The authors would like to thank <contact fullname="Yann Collet"/>, <contact fullname="Klaus Post"/>, <contact fullname="Adam Rice"/>, and members
of the Web Performance Working Group in the W3C for collaborating on the window
size issue and helping to formulate a solution.</t>
    </section>
    <section anchor="authors-addresses" numbered="false" removeInRFC="false" toc="include" pn="section-appendix.b">
      <name slugifiedName="name-authors-addresses">Authors' Addresses</name>
      <author initials="N." surname="Jaju" fullname="Nidhi Jaju" role="editor">
        <organization showOnFrontPage="true">Google</organization>
        <address>
          <postal>
            <street>Shibuya Stream, 3 Chome-21-3 Shibuya</street>
            <region>Shibuya City, Tokyo</region>
            <code>150-0002</code>
            <country>Japan</country>
          </postal>
          <email>nidhijaju@google.com</email>
        </address>
      </author>
      <author initials="W. F." surname="Handte" fullname="W. Felix P. Handte" role="editor">
        <organization showOnFrontPage="true">Meta Platforms, Inc.</organization>
        <address>
          <postal>
            <street>380 W 33rd St</street>
            <city>New York</city>
            <region>NY</region>
            <code>10001</code>
            <country>United States of America</country>
          </postal>
          <email>felixh@meta.com</email>
        </address>
      </author>
    </section>
  </back>
</rfc>
