fix(platform): match asset hashes of 8+ chars, not exactly 8#2846
Merged
Conversation
The static-asset cache rule (#2843) matched only exactly-8-char content hashes. Rollup extends a hash past 8 chars to break collisions between same-named chunks; a post-deploy HAR showed one of six queries-*.js with a 9-char hash falling to no-cache and being re-fetched every visit. Widen the pattern to {8,} and add a 9-char regression case. Only .js|.css under /assets/ match, so un-hashed public images and /canvas-libs/* stay excluded; fail-safe as before (never serves stale bytes).
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.
Problem
Follow-up to the static-asset caching fix (#2843). That rule marks content-hashed chunks
immutableby matching-[A-Za-z0-9_-]{8}\.(?:js|css)— exactly 8 hash chars. Rollup lengthens a hash past 8 chars to disambiguate same-named chunks, so a post-deploy HAR showed/assets/queries-LIOgKzLg2.js(9-char hash, one of sixqueries-*.js) falling tono-cacheand being re-downloaded on every visit. Fail-safe (never stale), but it leaves collision-extended chunks uncached — and that grows as chunks are added.Fix
Widen the pattern
{8}→{8,}(8-or-more). Handles any hash length; only.js|.cssunder/assets/match, so un-hashed public images (svg/png) and version-pinned/canvas-libs/*are still excluded. Fail-safe unchanged.Verification
bun run --filter @tale/platform test server.test.ts→ green (57), incl. a new 9-char case (/assets/queries-LIOgKzLg2.js→ immutable) that fails on{8}, passes on{8,}.bun run --filter @tale/platform typecheckclean;oxfmt --check+oxlintclean.Verified against the post-deploy HAR: the caching fix works (repeat visit ~243s → ~9.9s; 152/153 hashed assets from cache); this closes the last 9-char-hash gap.