Skip to content

Stamp the stylesheet and scripts with their content, so a deploy never pairs new HTML with old files - #31

Merged
kvlonge merged 1 commit into
mainfrom
fix/cache-bust-site-assets
Dec 3, 2026
Merged

kvlonge merged 1 commit into
mainfrom
fix/cache-bust-site-assets

Conversation

@kvlonge

@kvlonge kvlonge commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Why

After a deploy, the page could look broken until a hard refresh. index.html is fetched fresh, but stack.js and tools.js had no version and styles.css/theme.js relied on hand-bumped ?v= numbers, so browsers kept old copies (Cloudflare tells them to for 4 hours).

Changes

  • npm run stamp writes a content hash into each stylesheet and script link in index.html, e.g. stack.js?v=8b37b17e.
  • CI runs node scripts/stamp-assets.mjs --check and fails when a stamp is out of date.
  • README notes the step.

Verification

  • --check failed before stamping and passes after.
  • npm test: 9 passed.

…r pairs new HTML with old files

index.html linked styles.css and theme.js with hand-bumped versions and
stack.js and tools.js with none, so after a deploy a browser could keep
an old copy and show a broken page until a hard refresh. npm run stamp
now writes a content hash into each link, and CI fails when one is out
of date.
@kvlonge
kvlonge merged commit e81fd18 into main Dec 3, 2026
3 checks passed
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.

1 participant