<?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.18 (Ruby 3.3.3) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-httpbis-zstd-window-size-02" category="info" consensus="true" submissionType="IETF" updates="8878" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.22.0 -->
  <front>
    <title abbrev="Zstd Window Size">Window Sizing for Zstandard Content Encoding</title>
    <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-zstd-window-size-02"/>
    <author initials="N." surname="Jaju" fullname="Nidhi Jaju" role="editor">
      <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 initials="F." surname="Handte" fullname="W. Felix P. Handte" role="editor">
      <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 year="2024" month="August" day="06"/>
    <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 59?>

<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://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/httpwg/http-extensions/labels/zstd-window-size"/>.</t>
    </note>
  </front>
  <middle>
    <?line 68?>

<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" HTTP 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>
      <t>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">
      <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 and <xref target="RFC8878"/></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 158?>

<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:
H4sIAAAAAAAAA41Y7XLbuBX9j6e4Vf4kW1GOouzE1aSbKHay8W7suJYynrTT
6UAkJGFFEiwAWlE8eZd9ln2yngtQEmk7sx3/sAgC9/Pccy+YJInw2udqTNe6
zMyGpvqrLpe0MJb+6bwsM2kzOjGlV6Wnt2VqMrwWcj636mbMW7LWSSVS6dXS
2O2YdLkwQmQmLWUB8ZmVC59o5RfJyvtqrl3yFYeTTTicOBxOnj4Trp4X2jkN
hdsKx87ezt6Jsi7myo5FBuFjkZrSqdLVbkze1krUFa/j6fj4xbGAUSMhrZLw
SM0JDtAZjLel8jSzsnSVsV5sjF0vramrMb2fzS7fnE3FWm2xmo0FJcSWNf9j
BPghNUVlVbAtPsaYqF1MWmuHFVlVuUZQcOgoSL1RZQ0niFrq8RS9vYZZHP2f
+R1WC6lzRHIXtGSzfL0ZDYyFaJI2XY2Jl9346CjXzrtBfHk0wSt9o9zRZT2H
9qO2gCNWrf2qnsfDWAlv1BdYzr65o1zOVe6O7qYHB3MOtB9Tb6c2SghK70r5
PxI+WPki74loToK01yoJysd0T7mQtV8Zy+mBIQR4IeMXA/pF/laHhUWd5xFq
Fzpb6cMLaxjeKtPe2LAAa2Wpv4akjOlnY5a5Ci+ct0rBvelKz+utpCmeZdGn
EZ2sTKGSZ8NktHsZRatlkLE7cKL9tk8zs96a8B44gOrhj0+Tp08B7rhUl57r
4xdZyTIsqZjmks3+DVa/XgaTBgBcx9t3A3oPOHp1x9/rAb1Tuf5Cl50Nf+L3
ufKSLpFRlHrh+qiSdNCJwuj4KV3TaIT6n/poO9xDeNWGPgOonQhcfG47DG+H
XW8/TduuLtjc1esCJgQvRQkbYNcNKkMwcRyeRJKgiuYwSqZeiFNV5WZboMgc
mcWBovrwjnqMml6fUllS7RRlerFQlgsyIokYSY68oVwX2otCFaAqbJV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