<?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.11 (Ruby 2.6.4) -->
<?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="info"
      consensus="true"
      docName="draft-ietf-httpbis-zstd-window-size-00"
      ipr="trust200902"
      sortRefs="true"
      submissionType="IETF"
      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 abbrev="Zstd Window Size">Window Sizing for Zstandard Content Encoding</title>
      <author fullname="Nidhi Jaju"
               initials="N."
               role="editor"
               surname="Jaju">
         <organization>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 fullname="W. Felix P. Handte"
               initials="F."
               role="editor"
               surname="Handte">
         <organization>Meta Platforms, Inc.</organization>
         <address>
            <postal>
               <street>380 W 33rd St</street>
               <city>New York</city>
               <region>NY</region>
               <code>10001</code>
               <country>US</country>
            </postal>
            <email>felixh@meta.com</email>
         </address>
      </author>
      <date day="12" month="June" year="2024"/>
      <area>Web and Internet Transport</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><?line 58?>
         <t>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, causing interoperability issues. This document updates the window size limit in RFC8878 from a recommendation to a requirement in HTTP contexts.</t>
      </abstract>
      <note removeInRFC="true" title="About This Document">
         <t>The latest revision of this draft can be found at <eref target="https://httpwg.org/http-extensions/draft-ietf-httpbis-zstd-window-size.html"/>. Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-ietf-httpbis-zstd-window-size/"/>.</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/"/>.</t>
         <t>Source for this draft and an issue tracker can be found at <eref target="https://github.com/https://github.com/httpwg/http-extensions/labels/zstd-window-size"/>.</t>
      </note>
   </front>
   <middle><?line 67?>
      <section anchor="introduction">
         <name>Introduction</name>
         <t>Zstandard, or "zstd", specified in <xref target="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>An important property of Zstandard-compressed content is its Window_Size (<xref section="3.1.1.1.2" sectionFormat="comma" target="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>The minimum Window_Size is 1 KB. The maximum Window_Size is (1&lt;&lt;41) + 7*(1&lt;&lt;38) bytes, 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>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>
            <xref section="3.1.1.1.2" sectionFormat="comma" target="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>This document updates <xref target="RFC8878"/> to enforce Window_Size limits on the encoder and decoder for the "zstd" content coding.</t>
      </section>
      <section anchor="conventions-and-definitions">
         <name>Conventions and Definitions</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?>
      </section>
      <section anchor="window-size">
         <name>Window Size</name>
         <t>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"/>).</t>
      </section>
      <section anchor="security-considerations">
         <name>Security Considerations</name>
         <t>This document introduces no new security considerations beyond those discussed in <xref target="RFC8878"/>.</t>
      </section>
      <section anchor="iana-considerations">
         <name>IANA Considerations</name>
         <section anchor="zstd-iana-token">
            <name>Content Encoding</name>
            <t>This document updates the entry added in <xref target="RFC8878"/> to the "HTTP Content Coding Registry" within the "Hypertext Transfer Protocol (HTTP) Parameters" registry:</t>
            <dl>
               <dt>Name:</dt>
               <dd>
                  <t>zstd</t>
               </dd>
               <dt>Description:</dt>
               <dd>
                  <t>A stream of bytes compressed using the Zstandard protocol with a Window_Size of not more than 8 MB.</t>
               </dd>
               <dt>Reference:</dt>
               <dd>
                  <t>This document</t>
               </dd>
            </dl>
         </section>
      </section>
   </middle>
   <back>
      <references anchor="sec-normative-references" title="Normative References">
         <reference anchor="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"/>
            </front>
            <seriesInfo name="RFC" value="8878"/>
            <seriesInfo name="DOI" value="10.17487/RFC8878"/>
         </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>
      <?line 153?>
      <section anchor="acknowledgments" numbered="false">
         <name>Acknowledgments</name>
         <t>Zstandard was developed by Yann Collet.</t>
         <t>The authors would like to thank Yann Collet, Klaus Post, 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. Also, thank you to Nick Terrell for providing feedback that went into RFC 8478 and RFC 8878.</t>
      </section>
   </back>
</rfc>
