Serve hashed client chunks as immutable so warm page loads stop revalidating all 186 - #6684
Merged
atomantic merged 2 commits intoSep 9, 2026
Conversation
…idating all 186 The built UI was served with express.static defaults, so every content-hashed chunk under /assets/ went out with `Cache-Control: public, max-age=0`. A browser treats that as stale on arrival: measured against a spare-port server with a request-counting proxy and Chrome with service workers blocked (the default plain-HTTP tailnet posture, where no service worker can register), a warm dashboard load re-sent all 186 chunks as conditional GETs and got 186 304s back before the app could start. Over HTTP/1.1 at six connections per host that is ~31 sequential round-trip waves of pure revalidation on every reload. Vite renames a chunk whenever its bytes change and the `no-cache` index.html is what points at the current set, so `/assets/**` is safe to serve with `immutable, max-age=1y`. `mountClientDist` in services/assetMounts.js does that as a first tier and keeps the revalidate-per-load default for the rest of dist/ — `sw.js`, `manifest.json`, `fonts/`, `sky/`, `hdri/` are client/public files copied under stable names whose bytes do change. `index: false` stays on both so `/` still reaches the build-id-stamped SPA fallback, and a chunk the current build no longer ships still misses both tiers and 404s, which the stale-chunk reload depends on. Same measurement after the change: 0 asset requests on a warm load or reload, and a warm navigation to a not-yet-visited route fetches only its own new chunks (14 instead of 42).
…her than not HTML
atomantic
deleted the
cos/app-improve-portos-default-performance-mttjv4la/agent-90a874f2
branch
September 9, 2026 04:08
atomantic
restored the
cos/app-improve-portos-default-performance-mttjv4la/agent-90a874f2
branch
September 9, 2026 04:09
atomantic
deleted the
cos/app-improve-portos-default-performance-mttjv4la/agent-90a874f2
branch
September 9, 2026 04:09
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
express.staticdefaults, so every content-hashed chunk under/assets/went out asCache-Control: public, max-age=0, which a browser treats as stale on arrival. Measured with a request-counting proxy in front of a spare-port server and Chrome with service workers blocked (the default plain-HTTP tailnet posture, wheresw.jscannot register): a warm dashboard load re-sent all 186 chunks as conditional GETs and got 186304s back before the app could start.mountClientDistinservices/assetMounts.jsserves/assets/**aspublic, max-age=31536000, immutableand keeps the revalidate-per-load default for the rest ofdist/(sw.js,manifest.json,fonts/,sky/,hdri/areclient/public/files copied under stable names whose bytes do change).index: falsestays on both tiers so/still reaches the build-id-stamped SPA fallback, and a chunk the current build no longer ships still 404s, which the stale-chunk reload relies on./settingsfetches only its own 14 new chunks (was 42)./assets/requests//settingsTest plan
server/services/assetMounts.test.js: hashed chunk carries the immutable header;sw.jsandmanifest.jsonkeeppublic, max-age=0with an ETag;/reaches the SPA fallback, not the raw index.html; a stale chunk 404s instead of getting the SPA index.scripts/dev-proxy-drift.test.js(readsserver/index.jsas data) plus every other suite that readsserver/index.js: 703 tests green./assets/index-*.js→public, max-age=31536000, immutable;/sw.js→public, max-age=0;/→no-cache;/assets/index-STALEHASH.js→ 404 JSON.dist/.