Skip to content
quarry View Ticket
Login

View Ticket

HTTP compression for pages and API, with SSE excluded

Closed50643692665bb464e85d10966b056b2b894674c0Created 91.5 days agoUpdated 67.9 days ago
Description2026-08-31 11:53:49
Nothing is compressed today. Confirmed against the live forge: identical byte counts with and without Accept-Encoding: gzip, and no Content-Encoding on any response. The only compression in the tree is xfer/container.go (zlib, per the sync RFC) and a gzip reader in registrar.go.

Measured savings: timeline 309,584 to 36,599 (88%); ticket list 209,058 to 33,194 (84%); API timeline 30,190 to 7,090 (77%); src/btree.c page 2,335,223 to 196,463 (92%).

Benchmarked on the 310KB timeline page: gzip-1 50,688/1.1ms; gzip-6 37,166/3.3ms; gzip-9 36,593/5.1ms; brotli-4 37,725/2.0ms; brotli-5 34,551/3.0ms; brotli-6 33,790/3.5ms; brotli-11 29,973/247ms. Brotli q5 beats gzip-6 on BOTH size (-7%) and time, so there is no tradeoff to weigh; q11 is unusable for dynamic pages but right for static assets compressed once.

Honest scope: the forge is reached over Tailscale at 17.3MB/s, where this saves only a few ms. It matters for anyone remote — the btree.c page is 3.7s vs 0.3s at 5Mbps.

Brotli needs andybalholm/brotli (no stdlib support); gzip-only is a defensible dependency-free answer at 88% of the benefit.

TRAP: web.go has 22 text/event-stream writers. A naive middleware buffers and breaks Datastar streaming. Excluding SSE must be in the first commit, with a test asserting an SSE response carries no Content-Encoding and still flushes per event.

Acceptance: HTML and JSON responses negotiate encoding; SSE never compressed and still streams; a test pins both.

2026-09-01 01:08:21

Shipped. web.Compress wraps the mux (cmd/quarry/main.go), and text/event-stream is excluded by content type in internal/web/compress.go so SSE stays unbuffered. Verified live: a page fetch with Accept-Encoding: gzip comes back Content-Encoding: gzip, and the attention/chat/CI streams are untouched.