Skip to content

fix(web): mark static assets no-cache to stop CDN version skew - #108

Merged
WarlaxZ merged 1 commit into
mainfrom
fix/static-asset-cdn-caching
Sep 1, 2026
Merged

WarlaxZ merged 1 commit into
mainfrom
fix/static-asset-cdn-caching

Conversation

@WarlaxZ

@WarlaxZ WarlaxZ commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • tl.reccd.stream was throwing Cannot read properties of null (reading 'addEventListener') at app.ts:2152 on load. Cloudflare was caching /app.js at the edge for hours (confirmed two different cached copies of /app.js served simultaneously, Age: 4048 vs Age: 112) while index.html was always fetched fresh (DYNAMIC), since neither response carried a Cache-Control header from the origin.
  • After a deploy this can pair a fresh index.html with a stale cached app.js whose listeners expect an older DOM shape, until the CDN's default TTL expires.
  • src/web/server.ts now sends Cache-Control: no-cache on every static asset served (index.html, player.html, app.js/player.js/chunks, styles.css, fonts), forcing revalidation on each request instead of letting a downstream cache reuse a stale copy.

Test plan

  • npm test (3310 passed, including a new regression test asserting Cache-Control: no-cache on / and /app.js)
  • npm run typecheck
  • npm run lint (only the known pre-existing react-hooks/exhaustive-deps warning)
  • npm run build
  • Verified in a real browser against a fresh local build: headers present, no console errors
  • Reproduced the original error live on tl.reccd.stream and confirmed the root cause (two differently-sized cached /app.js responses) before fixing

Note: this needs a deploy to take effect on tl.reccd.stream, and since Cloudflare currently has a stale app.js cached there, purging its cache after deploying will make the fix effective immediately rather than waiting out the existing TTL.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MPpJwadYAkvKmYvDuMwg6n

app.js and index.html live at fixed, unhashed paths and every deploy
overwrites them in place. On tl.reccd.stream, Cloudflare cached app.js
at the edge for hours while index.html (no explicit header) was
always DYNAMIC, so a deploy could leave a fresh index.html paired with
a stale cached app.js until the CDN's TTL expired — reproduced as two
different cached copies of /app.js served simultaneously, one of them
wired for a DOM shape the served HTML no longer matched, which threw
Cannot read properties of null (reading 'addEventListener') on load.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MPpJwadYAkvKmYvDuMwg6n
@WarlaxZ
WarlaxZ merged commit bcd0a82 into main Sep 1, 2026
6 checks passed
@WarlaxZ
WarlaxZ deleted the fix/static-asset-cdn-caching branch September 1, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants