<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version 1.7.11 (Ruby 3.2.4) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-jaju-httpbis-zstd-window-size-01" category="info" consensus="true" submissionType="IETF" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.21.0 -->
  <front>
    <title abbrev="Zstd Window Size">Window Sizing for Zstandard Content Encoding</title>
    <seriesInfo name="Internet-Draft" value="draft-jaju-httpbis-zstd-window-size-01"/>
    <author fullname="Nidhi 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">
      <organization>Meta Platforms, Inc.</organization>
      <address>
        <postal>
          <street>380 W 33rd St</street>
          <city>New York, NY 10001</city>
          <country>US</country>
        </postal>
        <email>felixh@meta.com</email>
      </address>
    </author>
    <date year="2024" month="May" day="20"/>
    <area>Web and Internet Transport</area>
    <workgroup>HTTPBIS</workgroup>
    <keyword>zstd</keyword>
    <keyword>zstandard</keyword>
    <keyword>compression</keyword>
    <keyword>content encoding</keyword>
    <keyword>application/zstd</keyword>
    <abstract>
      <?line 50?>

<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">
      <name>About This Document</name>
      <t>
        The latest revision of this draft can be found at <eref target="https://nidhijaju.github.io/draft-zstd-window-size/draft-jaju-httpbis-zstd-window-size.html"/>.
        Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-jaju-httpbis-zstd-window-size/"/>.
      </t>
      <t>
        Discussion of this document takes place on the
        HTTPBIS 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/nidhijaju/draft-zstd-window-size"/>.</t>
    </note>
  </front>
  <middle>
    <?line 59?>

<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 of 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, when using the "zstd" Content Coding
(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">
      <name>Normative References</name>
      <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"/>
          <abstract>
            <t>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>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>This document replaces and obsoletes RFC 8478.</t>
          </abstract>
        </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"/>
          <abstract>
            <t>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">
        <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>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>
    </references>
    <?line 145?>

<section numbered="false" anchor="acknowledgments">
      <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>
  <!-- ##markdown-source:
H4sIAAAAAAAAA41Y7XLbuBX9j6e4lf8kW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