Part of the API freeze (#110). Decided: in before rc.1. It adds a createApp option, and it has to be designed together with ETag (#114), because an ETag describes the body before encoding.
Shape:createApp({ compression: true | { threshold?, encodings? } }), off by default.
Negotiates on Accept-Encoding, with br over gzip, and sets Content-Encoding and Vary: Accept-Encoding.
Skips a response that is already encoded, HEAD, 204/304, bodies under threshold (default 1 KiB), and types that don't compress (images, video, zip, anything outside text/*, JSON, JS, SVG, XML, wasm).
Streams (SSE, ndjson) compress too, but they must flush every event: a buffered SSE is a broken SSE. If a runtime can't flush, streams are left uncompressed there.
Runtimes:CompressionStream exists on all four for gzip. For br, use node:zlib on Node, Deno and Bun, and on Workers fall back to gzip or leave it to Cloudflare, which already compresses at the edge. Core keeps its one runtime dependency; nothing new gets installed.
Tests: negotiation (q-values, identity, *), threshold, skip list, Vary present, a streamed SSE arrives event by event, and the same bytes on all four runtimes.
Part of the API freeze (#110). Decided: in before rc.1. It adds a `createApp` option, and it has to be designed together with ETag (#114), because an ETag describes the body before encoding.
**Shape:** `createApp({ compression: true | { threshold?, encodings? } })`, off by default.
- Negotiates on `Accept-Encoding`, with `br` over `gzip`, and sets `Content-Encoding` and `Vary: Accept-Encoding`.
- Skips a response that is already encoded, `HEAD`, `204`/`304`, bodies under `threshold` (default 1 KiB), and types that don't compress (images, video, zip, anything outside `text/*`, JSON, JS, SVG, XML, wasm).
- Streams (SSE, ndjson) compress too, but they must flush every event: a buffered SSE is a broken SSE. If a runtime can't flush, streams are left uncompressed there.
**Runtimes:** `CompressionStream` exists on all four for gzip. For `br`, use `node:zlib` on Node, Deno and Bun, and on Workers fall back to gzip or leave it to Cloudflare, which already compresses at the edge. Core keeps its one runtime dependency; nothing new gets installed.
**Tests:** negotiation (q-values, `identity`, `*`), threshold, skip list, `Vary` present, a streamed SSE arrives event by event, and the same bytes on all four runtimes.
Fixed in 26.11.0-rc.1 (3296189). From the changelog:
createApp({ compression }) (#112, D13): response compression, off by default. true, or { threshold?, encodings? } (default 1024 bytes and ['br', 'gzip'], in preference order). Accept-Encoding is negotiated with q-values, identity, * and q=0, and ties go to server preference. Text, JSON, JavaScript, ndjson, SVG, XML and wasm are compressed. A response that already has Content-Encoding or Content-Range, has no Content-Type, or says Cache-Control: no-transform is left alone. Vary: Accept-Encoding is added wherever the request decided the outcome: identity clients, HEAD and every 304. A body under the threshold gets none: it is sent identity whatever the client accepts, and Deno pays about 10% of a small request for the header (about 3% on Bun). On the edge, where Cloudflare encodes, every compressible response keeps Vary. Content-Length is dropped from an encoded body. SSE and ndjson streams are compressed too, flushed after every event, error frame and ping, so each event decodes when it arrives. Per runtime: - Node and Bun: async node:zlib, br at quality 4. - Deno: the same code, but Deno 2.9 runs zlib's async API on the main thread, so compression costs event-loop time there (about 4× slower than Node for a 51 KB gzip under load). - Edge: core never encodes and sets only Vary; Cloudflare applies the encoding. Edge is recognised through edgeHandler or by detecting workerd at createApp. ETags (etag: true) are taken before encoding and stay the same across codings. No dependency; invalid options throw.
Fixed in **26.11.0-rc.1** (`3296189`). From the changelog:
- **`createApp({ compression })`** (#112, D13): response compression, off by default. `true`, or `{ threshold?, encodings? }` (default `1024` bytes and `['br', 'gzip']`, in preference order). `Accept-Encoding` is negotiated with q-values, `identity`, `*` and `q=0`, and ties go to server preference. Text, JSON, JavaScript, ndjson, SVG, XML and wasm are compressed. A response that already has `Content-Encoding` or `Content-Range`, has no `Content-Type`, or says `Cache-Control: no-transform` is left alone. `Vary: Accept-Encoding` is added wherever the request decided the outcome: identity clients, `HEAD` and every `304`. A body under the threshold gets none: it is sent identity whatever the client accepts, and Deno pays about 10% of a small request for the header (about 3% on Bun). On the edge, where Cloudflare encodes, every compressible response keeps `Vary`. `Content-Length` is dropped from an encoded body. SSE and ndjson streams are compressed too, flushed after every event, error frame and ping, so each event decodes when it arrives. Per runtime: - **Node and Bun:** async `node:zlib`, br at quality 4. - **Deno:** the same code, but Deno 2.9 runs zlib's async API on the main thread, so compression costs event-loop time there (about 4× slower than Node for a 51 KB gzip under load). - **Edge:** core never encodes and sets only `Vary`; Cloudflare applies the encoding. Edge is recognised through `edgeHandler` or by detecting workerd at `createApp`. ETags (`etag: true`) are taken before encoding and stay the same across codings. No dependency; invalid options throw.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Part of the API freeze (#110). Decided: in before rc.1. It adds a
createAppoption, and it has to be designed together with ETag (#114), because an ETag describes the body before encoding.Shape:
createApp({ compression: true | { threshold?, encodings? } }), off by default.Accept-Encoding, withbrovergzip, and setsContent-EncodingandVary: Accept-Encoding.HEAD,204/304, bodies underthreshold(default 1 KiB), and types that don't compress (images, video, zip, anything outsidetext/*, JSON, JS, SVG, XML, wasm).Runtimes:
CompressionStreamexists on all four for gzip. Forbr, usenode:zlibon Node, Deno and Bun, and on Workers fall back to gzip or leave it to Cloudflare, which already compresses at the edge. Core keeps its one runtime dependency; nothing new gets installed.Tests: negotiation (q-values,
identity,*), threshold, skip list,Varypresent, a streamed SSE arrives event by event, and the same bytes on all four runtimes.Merged into develop in #149 (CARD-16, FPRD-001c, 2026-10-23). Left open until the 1c acceptance gate (CARD-22), per the 1a/1b convention.
Fixed in 26.11.0-rc.1 (
3296189). From the changelog:createApp({ compression })(#112, D13): response compression, off by default.true, or{ threshold?, encodings? }(default1024bytes and['br', 'gzip'], in preference order).Accept-Encodingis negotiated with q-values,identity,*andq=0, and ties go to server preference. Text, JSON, JavaScript, ndjson, SVG, XML and wasm are compressed. A response that already hasContent-EncodingorContent-Range, has noContent-Type, or saysCache-Control: no-transformis left alone.Vary: Accept-Encodingis added wherever the request decided the outcome: identity clients,HEADand every304. A body under the threshold gets none: it is sent identity whatever the client accepts, and Deno pays about 10% of a small request for the header (about 3% on Bun). On the edge, where Cloudflare encodes, every compressible response keepsVary.Content-Lengthis dropped from an encoded body. SSE and ndjson streams are compressed too, flushed after every event, error frame and ping, so each event decodes when it arrives. Per runtime: - Node and Bun: asyncnode:zlib, br at quality 4. - Deno: the same code, but Deno 2.9 runs zlib's async API on the main thread, so compression costs event-loop time there (about 4× slower than Node for a 51 KB gzip under load). - Edge: core never encodes and sets onlyVary; Cloudflare applies the encoding. Edge is recognised throughedgeHandleror by detecting workerd atcreateApp. ETags (etag: true) are taken before encoding and stay the same across codings. No dependency; invalid options throw.