feat: robust cache busting on deployment#3
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Conversation
Layer 1 — HTML meta tags (all 3 index.html files): Cache-Control: no-cache, no-store, must-revalidate Pragma: no-cache / Expires: 0 Layer 2 — nginx configs (all 3 UIs): index.html + SPA fallback: no-cache, no-store, must-revalidate /assets/*: public, immutable (1 year) — Vite content-hashed filenames /sw.js: no-cache, no-store — forces browser to detect new SW /manifest.json: no-cache, must-revalidate Layer 3 — APISIX gateway (3 web app routes): response-rewrite plugin injects Cache-Control headers /assets/* priority 20: immutable (hashed by Vite) /sw.js priority 15: no-cache /* priority 10: no-cache for HTML Layer 4 — Service worker version-based cache clearing: CACHE_VERSION stamped by Vite build plugin (sw-version-stamp) activate handler purges ALL caches not matching current version SW_UPDATED message notifies open tabs Client shows 'new version available' banner with reload button Layer 5 — Client-side SW registration: updateViaCache: 'none' — bypass HTTP cache for sw.js fetch Periodic update check every 60s controllerchange listener auto-reloads on SW takeover Layer 6 — Vite build config: Explicit content-hash filenames: assets/[name]-[hash].js swVersionStamp plugin writes unique hash into dist/sw.js Also: production Dockerfiles for web2 + tenant_admin (were running dev mode) Co-Authored-By: Patrick Munis <pmunis@gmail.com>
Contributor
Author
Original prompt from Patrick
|
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Vite already content-hashes JS/CSS chunks, but
index.htmlcan be cached by the browser or APISIX — causing users to load stale entry points that reference old chunk filenames. This PR adds 6 layers of cache busting to guarantee users always get fresh code on deploy:Layer 1 — HTML
<meta>tags (all 3index.html)Layer 2 — nginx configs (new for
web2+tenant_admin, updated for54link_admin)Layer 3 — APISIX
response-rewriteplugin (3 web app routes)Priority routing:
/assets/*(p20, immutable) >/sw.js(p15, no-cache) >/*(p10, no-cache for HTML).Layer 4 — Service worker version-based cache purge
CACHE_VERSIONis stamped at build time by a Vite plugin. On activate, the SW deletes all caches not matching the current version and postsSW_UPDATEDto all open tabs.Layer 5 — Client-side SW registration
updateViaCache: 'none'onregister()— bypasses HTTP cache for sw.jsregistration.update()controllerchangeauto-reloads the pageLayer 6 — Vite build config
Explicit
assets/[name]-[hash].jsoutput +swVersionStamp()plugin that writes a unique MD5 hash intodist/sw.jsatcloseBundle.Also
web2andtenant_adminDockerfiles upgraded from dev mode (npm run dev) to production builds (multi-stage → nginx).Link to Devin session: https://app.devin.ai/sessions/07858e6781a543618f2cdd22ec11ac24
Requested by: @munisp