fix(server): Cache-Control no-cache for web assets (stop stale builds) #99

Merged
funman300 merged 1 commits from fix/web-no-cache-headers into master 2026-06-24 01:45:09 +00:00
Owner

Returning players kept seeing stale builds after a deploy. The origin serves the new files (verified 8/8 cache-busted), but the server sends no Cache-Control on the web router, so browsers heuristically cache the include_str!-compiled HTML and the fixed-name wasm-bindgen output (canvas.js, canvas_bg.wasm, …) indefinitely — even through a hard reload in Firefox.

Adds Cache-Control: no-cache in the security_headers middleware (wraps the web router). Browsers revalidate before using a cached copy; ServeDir`s Last-Modified/ETag make unchanged assets a cheap 304, changed ones re-fetch. Fixes the recurring stale-build problem.

Note: this is the delivery fix. The actual wgpu 2048 canvas fix (#98) is already deployed and confirmed live at the origin; it just needs Rhys on a fresh (uncached) load to verify it renders.

🤖 Generated with Claude Code

Returning players kept seeing stale builds after a deploy. The origin serves the new files (verified 8/8 cache-busted), but the server sends **no Cache-Control** on the web router, so browsers heuristically cache the `include_str!`-compiled HTML and the fixed-name wasm-bindgen output (`canvas.js`, `canvas_bg.wasm`, …) indefinitely — even through a hard reload in Firefox. Adds `Cache-Control: no-cache` in the `security_headers` middleware (wraps the web router). Browsers revalidate before using a cached copy; ServeDir`s Last-Modified/ETag make unchanged assets a cheap 304, changed ones re-fetch. Fixes the recurring stale-build problem. Note: this is the *delivery* fix. The actual wgpu 2048 canvas fix (#98) is already deployed and confirmed live at the origin; it just needs Rhys on a fresh (uncached) load to verify it renders. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
funman300 added 1 commit 2026-06-24 01:45:00 +00:00
Returning players kept getting stale builds: after the /play canvas fix
deployed, the origin served the new play.html (verified — 8/8 cache-busted
requests) but browsers still rendered the old one even after a hard reload.

Cause: the server sets no Cache-Control on the web router. The HTML pages are
include_str!'d into the binary and the wasm-bindgen output (canvas.js,
canvas_bg.wasm, solitaire_wasm.*) uses fixed filenames that change in place on
every deploy, so browsers heuristically cache them indefinitely.

Add `Cache-Control: no-cache` in the security_headers middleware (which wraps
the web router). Browsers now revalidate before using a cached copy; ServeDir
supplies Last-Modified/ETag so unchanged assets still return a cheap 304, while
changed ones (a new deploy) are re-fetched. Stops the stale-build problem for
everyone going forward.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
funman300 merged commit 1e0619897a into master 2026-06-24 01:45:09 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: funman300/Ferrous-Solitaire#99