Asset cache busting via import map and ASSETS_VERSION#92
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BreakEscape::ASSETS_VERSION(defaults to gemVERSION, overridable viaBREAK_ESCAPE_ASSETS_VERSIONenv var) so a single version bump busts the cache for all assets on deploybe_asset_pathERB helper that appends?v=VERSIONto every CSS, JS, and image URL in templatesbreak_escape_import_maphelper 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?v=Xversion strings from JSimportstatements so the global import map covers all modules uniformlydocs/CACHE_BUSTING.mdcovering the nginx/Cloudflare checklist, development mode testing, and post-deploy verification stepsTest plan
<script type="importmap">present in<head>with every/break_escape/js/path mapped to a versioned URL<link>and<script src>tags for/break_escape/carry?v=VERSIONBREAK_ESCAPE_ASSETS_VERSION=testin the environment, reload — all URLs update to?v=testcurl -I <game-page-url>returnsCF-Cache-Status: DYNAMICorBYPASS, notHITGenerated by Claude Code