hZflow — compression between server and browser
hZflow is the hyperZip idea applied to HTTP. A web server compresses every response the same way, usually with one fixed codec at one fixed level. hZflow classifies each response instead, tries every codec the receiver can decode and sends the smallest. What a single page never shows — how similar it is to the other pages on the same site — is carried by dictionaries.
The key decision: the browser already has the decoders. Everything goes out as ordinary Content-Encoding, so the client needs no script, plugin or app. Dictionaries follow RFC 9842 and are trained per route family. Every page becomes the dictionary for the next page view, and a new version of a script uses the previous version as its dictionary.
Measured on real sites
Frozen snapshots of real sites, split into a training half and a test half, with every dictionary path round-trip-verified against the reference tools. The table shows how many bytes are left of every 100 kB, so lower is better:
| site and content | gzip -9 | brotli -q11 | hZflow, trained dictionary | hZflow, navigating |
|---|---|---|---|---|
| Wikipedia, 333 articles | 17.6 kB | 13.9 kB | 7.7 kB | 5.7 kB |
| SVT, 40 news pages | 17.6 kB | 11.8 kB | 7.2 kB | 4.2 kB |
| MDN, 51 reference pages | 12.7 kB | 9.5 kB | 6.2 kB | 2.3 kB |
| GitHub, 26 pages | 21.1 kB | 10.1 kB | 8.4 kB | 5.8 kB |
| GitHub API, 40 JSON responses | 22.8 kB | 19.4 kB | 10.4 kB | 8.8 kB |
| hemsogrisen.se, 40 pages | 27.9 kB | 23.6 kB | 10.8 kB | 9.3 kB |
On MDN, a reader clicking from page to page receives a quarter of what brotli at its maximum setting would send. Measured against zstd, Caddy's default, everyday traffic comes out 35–48 % smaller and navigation 60–90 % smaller.
Where the dictionaries make the difference
Synthetic but repeatable, from the project's benchmark, at the settings used in production:
| content | raw | gzip | zstd | brotli | hZflow (dictionary) |
|---|---|---|---|---|---|
| 40 product pages, JSON API | 424.0 kB | 68.4 kB | 63.7 kB | 54.6 kB | 38.2 kB |
| 10 reports, JSON API | 46.8 kB | 10.0 kB | 8.3 kB | 7.3 kB | 6.5 kB |
an app.js update | 2.4 kB | 1.2 kB | 1.2 kB | 1.0 kB | 0.1 kB |
The last row is the delta path: the previous version of the script is the dictionary, so an update costs about an eighth of what brotli would send.
Images, streams and never feeling slow
- Images: JPEG goes as bit-exact JPEG XL to browsers that support it, otherwise AVIF or WebP. PNG goes as lossless WebP, 41 % smaller with every pixel verified identical.
- Mobile: large photos are scaled down for phones and never scaled up. On hemsogrisen.se a 2400-pixel photo becomes 43 kB on a phone instead of 128 kB.
- Streams: server-sent events and WebSockets can go through a zstd stream, flushed per event, so live updates stay live.
- Never slower: the first time content passes through, it goes out immediately with a fast codec. The best version is prepared in the background and cached by content hash for the next visitor. Measured live: a cold image goes out in 32 ms, and the next request gets AVIF, 57 % smaller, in 19 ms.
In production
This site runs through hZflow, along with 48 other sites on the same server. Adding a domain takes one config block and one line in Caddy, and the origin server is not touched. Responses marked no-transform are passed through untouched, as RFC 9111 requires.
The code is still private.