httpd: stamp the stylesheet hash on its URL !445

merged merged by cmc on 2026-09-20 07:07 UTC · krz/gitbay:style-version into main

Discussion

cmc

/static/style.css was served public, max-age=86400, must-revalidate at an unversioned URL. must-revalidate only forces a check once freshness expires, so for a day after a deploy a browser rendered the new markup against its old stylesheet and the ETag from #132 was never consulted.

Seen on a phone minutes after v1.31.0 deployed: the cached sheet predated !440, so .railopt, .railmore and .raildrop had no rules. Every rail icon showed instead of collapsing to five, the More menu appeared at a width that hides it, and its drop rendered as a line of inline links across the rail.

The hash that was already the ETag is split out as stylesheetHash and exported to the template layer as web.StyleVersion, which the layout stamps on the link as ?v=. A deploy changes the URL, so a cached copy cannot answer it. A request carrying the current hash names bytes that cannot change and is served max-age=31536000, immutable, dropping the revalidation round trip; the bare URL keeps the policy it had.

TestStylesheetURLCarriesTheBuildHash renders a page and asserts the link carries the hash, then checks both cache policies. It fails without the layout change.

Closes #239