Offer zstd as an additional HTTP compression option when your server and clients negotiate it through Accept-Encoding, while preserving Brotli and gzip fallbacks. On three enterno.io files, zstd level 3 encoded faster than Brotli level 5 but produced larger output. The right choice depends on server load, caching and transfer cost.

Zstandard is the compression algorithm defined in RFC 8878; HTTP uses the zstd coding token. Enabling it for a website is more than setting a codec flag. The client must advertise support, the server must select an acceptable representation, and intermediary caches must distinguish variants. We measured real HTML and JavaScript files from enterno.io to show the trade-off.
How HTTP negotiation works
GET /assets/app.js HTTP/2
Accept-Encoding: gzip, br, zstd
HTTP/2 200
Content-Encoding: zstd
Vary: Accept-EncodingAccept-Encoding is a request header and Content-Encoding describes the returned body. If the client did not advertise zstd, do not send a zstd response. Vary: Accept-Encoding tells shared caches to key variants by this request header. Clients without zstd should receive an acceptable Brotli, gzip or uncompressed response. Compression belongs at the HTTP representation layer, while the underlying JS file keeps its usual media type.
Smaller output does not automatically make a request faster. A tiny response is often dominated by latency. A large script benefits from fewer transferred bytes. Dynamic HTML can make CPU time on every request the limiting factor. Precompressed static files are a different operational case from compressing every response at runtime.

Results on HTML and two JavaScript files
We downloaded the public home-page HTML and two enterno.io JavaScript files. We compressed identical input bytes with gzip level 6, Brotli levels 5 and 11, and zstd levels 3 and 15. After warm-up, we used the median encoding time from 20 runs. The numbers describe one local CPU and these particular files, not a browser or network benchmark.
| File | Raw size | gzip 6 | Brotli 5 | zstd 3 | Brotli 11 | zstd 15 |
|---|---|---|---|---|---|---|
| HTML | 261,127 B | 48,240 B / 2.15 ms | 39,949 B / 2.58 ms | 46,280 B / 0.45 ms | 35,196 B / 228 ms | 39,488 B / 20.20 ms |
| app.js | 121,922 B | 33,182 B / 1.59 ms | 31,047 B / 1.64 ms | 35,212 B / 0.33 ms | 26,906 B / 114.79 ms | 29,555 B / 10.92 ms |
| vendor.js | 208,493 B | 70,705 B / 3.21 ms | 67,403 B / 3.44 ms | 73,083 B / 0.73 ms | 60,994 B / 232.41 ms | 64,363 B / 16.65 ms |
For all three files, Brotli 5 was smaller than zstd 3, while zstd 3 encoded faster. Brotli 11 reduced bytes further but required much more encoding time. That can be reasonable when immutable assets are precompressed once. It does not justify compressing every dynamic response at the slowest setting. No codec wins for every file and workload.
Choose by workload
| Situation | Useful starting point | What to inspect |
|---|---|---|
| Cached static JS and CSS | Precompressed Brotli and gzip; test zstd too | Size and cache hit rate |
| Dynamic HTML under load | Fast gzip, Brotli or zstd settings | CPU p95 and TTFB |
| Client without zstd | Brotli or gzip fallback | Correct representation |
| Very small response | Check if compression helps | Transferred bytes |
Already compressed WebP and AVIF images rarely gain much from an additional HTTP compression pass. Focus on text HTML, CSS, JavaScript and JSON. If a CDN recompresses origin responses, understand which layer chooses the final codec. A response must not be compressed twice.
Check your own server
Request the same URL with different Accept-Encoding values. Inspect Content-Encoding, Vary, status and actual body size. The enterno.io HTTP header tool can show response headers, while curl gives a repeatable local check.
curl -sSI -H 'Accept-Encoding: zstd, br, gzip' https://example.com/app.js
curl -sSI -H 'Accept-Encoding: gzip' https://example.com/app.js
curl -sSI -H 'Accept-Encoding: identity' https://example.com/app.js
# each Content-Encoding must match a supported client coding;
# Vary should include Accept-EncodingUse GET to compare transferred bodies because some stacks handle HEAD differently. Record TTFB and total time with both cold and warm cache. Repeat on several representative files. If network phases dominate, the curl timing guide helps put byte savings in context.
Safe rollout
- Record your current gzip/Brotli behavior and cache configuration.
- Confirm the server or CDN actually supports zstd as an HTTP content coding. Do not infer native module support from a product name.
- Enable zstd for a small set of text URLs and test clients with and without support.
- Compare compressed size, CPU, TTFB and decoding errors under realistic traffic.
- Expand only where the measured trade-off helps, then follow field metrics and cache behavior.
When TTFB rises, check whether large dynamic responses are compressed for every request. When a client receives unreadable data, inspect the content coding and intermediary cache. When variants are mixed, inspect Vary and cache keys. Correct negotiation matters more than a small byte saving.
How we made this
In November 2026 we saved three public enterno.io files and compressed the same raw bytes locally. The method.py script and data.json are stored with the draft. The table reports medians after warm-up and 20 repetitions. This test excludes network delay, browser decoding, CDN behavior and a representative sample of websites. We checked HTTP semantics against RFCs and MDN.
Interpret size and time together
For our HTML, zstd 3 and Brotli 5 differed by 6,331 bytes, while encoding took roughly 0.45 versus 2.58 ms. If HTML is personalized and cannot be cached, the server pays this CPU cost for every response. If it is static, a build can compress it once and serve it repeatedly without runtime encoding. Transfer size may then matter more. Other HTML inputs and compression settings can change the trade-off.
For app.js, Brotli 11 reduced the file to 26,906 bytes and zstd 15 to 29,555 bytes, but both high settings took longer to encode than fast settings. A build pipeline can do that work once. Confirm the CDN serves the precompressed asset without recompressing it. Local codec time alone does not describe user response time after deployment.
For vendor.js, fast zstd 3 produced 73,083 bytes and Brotli 5 produced 67,403. The difference on the wire may matter on a slow connection, but it also depends on parallel requests. If the file is already in the browser cache, neither encoding is involved in a repeat load. Check cache misses and the share of new visitors before optimizing a rarely transferred asset.
Rollout checklist
| Test | Expected outcome |
|---|---|
| Client advertises zstd | Server may serve zstd when available |
| Client advertises gzip only | No zstd body |
| Client requests identity | Uncompressed representation or an allowed server response |
| Repeat through CDN | Coding matches each request |
| Postrelease check | Errors, TTFB and CPU stay within budget |
Compare field LCP separately from local encoding time: one number cannot prove the other. The field-data guide explains why one synthetic run is insufficient. Use the launch monitoring checklist to track the release.
Verify cache variants
Request one URL as a zstd-capable client, as a gzip-only client, and as a client asking for an uncompressed representation. Repeat after the CDN cache is warm. If the cache ignores Accept-Encoding, one client may receive a body it cannot decode. That appears as a broken script rather than a small performance regression.
Interpret Content-Length carefully: streaming responses may omit it. Save the actual response body and check size, coding and successful decompression. For JavaScript, confirm that the page still runs. Some tools transparently decode responses and display the decoded size. Label exactly which size your report uses.
Precompressed variants must match the same source asset version. If a deployment updates JavaScript but retains an old .br or .zst file, browsers can receive different code. Verify the source hash and variant contents during the build. Dynamic HTML has no reusable artifact, so measure CPU under realistic request rates and watch overload. The CLS diagnostic guide can help separate a visual regression from the compression change.
For small responses, account for headers and transport separately. Our table records compressed body size only; it does not measure TLS, HTTP headers or packets. If savings are only a few hundred bytes, extra cache variation may cost more than saved traffic. Do not decide from one file. Add representative JSON responses, HTML from several templates and JavaScript of different sizes to your own sample.
Record raw size, codec level, encode and decode times, repetition count, CPU model and cache state. This makes a comparison reproducible after a library or CDN change. Label a local test as local: a compressor benchmark cannot measure a visitor's network delay.
If the benefit is real, document the rollout as a controlled experiment: record the traffic share, codec settings and observation period. Roll back if script load errors or response latency rise. After rollback, request every variant through the CDN again; an obsolete compressed body can remain cached longer than the server configuration.
FAQ
Should zstd replace Brotli?
There is no universal answer. Brotli 5 made our JS files smaller, whereas zstd 3 encoded faster. Keep fallbacks and test your workload.
Why was zstd 15 not the smallest?
Compression levels across codecs are not equivalent. Brotli 11 produced smaller files in this sample; other input data can differ.
Is Vary enough for caching?
The header declares the response dependency, but your CDN and application cache must actually store variants separately. Test multiple request headers.