Skip to content

Asset cache busting via import map and ASSETS_VERSION#92

Merged
cliffe merged 4 commits into
mainfrom
claude/asset-cache-busting-erk5zg
Jun 11, 2026
Merged

Asset cache busting via import map and ASSETS_VERSION#92
cliffe merged 4 commits into
mainfrom
claude/asset-cache-busting-erk5zg

Conversation

@cliffe

@cliffe cliffe commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Introduces BreakEscape::ASSETS_VERSION (defaults to gem VERSION, overridable via BREAK_ESCAPE_ASSETS_VERSION env var) so a single version bump busts the cache for all assets on deploy
  • Adds be_asset_path ERB helper that appends ?v=VERSION to every CSS, JS, and image URL in templates
  • Adds break_escape_import_map helper that injects a <script type="importmap"> block into page heads, rewriting all 147 ES6 module import paths to versioned URLs — this closes the gap where nginx's infinite cache would serve stale sub-modules even after the entry point was versioned
  • Strips the 40+ hardcoded per-file ?v=X version strings from JS import statements so the global import map covers all modules uniformly
  • Adds docs/CACHE_BUSTING.md covering the nginx/Cloudflare checklist, development mode testing, and post-deploy verification steps

Test plan

  • View source on the game page — <script type="importmap"> present in <head> with every /break_escape/js/ path mapped to a versioned URL
  • All <link> and <script src> tags for /break_escape/ carry ?v=VERSION
  • DevTools Network tab — every JS module request (including sub-modules loaded by other modules) shows a versioned URL
  • Set BREAK_ESCAPE_ASSETS_VERSION=test in the environment, reload — all URLs update to ?v=test
  • Cloudflare Cache Level is Standard (not Ignore Query String)
  • curl -I <game-page-url> returns CF-Cache-Status: DYNAMIC or BYPASS, not HIT

Generated by Claude Code

cliffe added 4 commits June 11, 2026 16:54
All JS/CSS/asset URLs now carry a ?v=<VERSION> query param derived from
BreakEscape::ASSETS_VERSION (defaults to gem VERSION, overridable via
BREAK_ESCAPE_ASSETS_VERSION env var). A dynamic import map is injected
into page heads so the browser rewrites every internal ES6 module import
to the versioned URL, closing the cache gap that query-param versioning
on only the entry point would leave open. Bump VERSION (or set the env
var) on deploy to bust nginx/Cloudflare infinite-cache for all clients.

https://claude.ai/code/session_01FAHp4aNpzSAxXX81PFeSAq
All 40+ per-file manual version strings in import statements are removed.
Versioning is now handled entirely by the import map injected at page load,
so bumping ASSETS_VERSION (or BREAK_ESCAPE_ASSETS_VERSION env var) busts
the cache for every JS module uniformly on deploy.

https://claude.ai/code/session_01FAHp4aNpzSAxXX81PFeSAq
Covers how versioned URLs and the import map work, the nginx/Cloudflare
checklist, and step-by-step tests to verify correct behaviour after a deploy.

https://claude.ai/code/session_01FAHp4aNpzSAxXX81PFeSAq
@cliffe cliffe merged commit bb36c8d into main Jun 11, 2026
2 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