nattviken

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 contentgzip -9brotli -q11hZflow, trained dictionaryhZflow, navigating
Wikipedia, 333 articles17.6 kB13.9 kB7.7 kB5.7 kB
SVT, 40 news pages17.6 kB11.8 kB7.2 kB4.2 kB
MDN, 51 reference pages12.7 kB9.5 kB6.2 kB2.3 kB
GitHub, 26 pages21.1 kB10.1 kB8.4 kB5.8 kB
GitHub API, 40 JSON responses22.8 kB19.4 kB10.4 kB8.8 kB
hemsogrisen.se, 40 pages27.9 kB23.6 kB10.8 kB9.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:

contentrawgzipzstdbrotlihZflow (dictionary)
40 product pages, JSON API424.0 kB68.4 kB63.7 kB54.6 kB38.2 kB
10 reports, JSON API46.8 kB10.0 kB8.3 kB7.3 kB6.5 kB
an app.js update2.4 kB1.2 kB1.2 kB1.0 kB0.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

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.

← All projects