fix(web): bypass data cache for large reference categories#141
Merged
Conversation
…icle)
Next 15 hardcodes a 2 MB per-entry limit on the fetch data cache.
The items reference listing currently weighs ~3.4 MB and the
vehicle listing ~4 MB (per memory/wiki-reference-page-sizes.md), so
every render that calls `getCategoryBundle('item')` /
`getCategoryBundle('vehicle')` logged:
Failed to set Next.js data cache for
http://starstats-api:8080/v1/reference/item,
items over 2MB can not be cached (3441446 bytes)
The fetch still succeeded — pages rendered fine — but the cache
attempt was wasted serialization work and the recurring warning
muddied the prod logs.
Fix: `kbCacheOpts` now takes the category as an optional arg and
returns `cache: 'no-store'` for the known-large set (LARGE_CATEGORIES
= item + vehicle). Other categories (weapon, location) keep the 1h
revalidate. STARSTATS_DISABLE_FETCH_CACHE=1 still wins for the
Playwright scenario-isolation path.
React's request-level fetch dedup still applies — same-URL fetches
within a single server render share an upstream call regardless of
cache mode. The cost is one 3.4 MB inbound transfer per page render
that touches items, which is the cost we were already paying because
Next refused to cache it anyway.
If a third category ever crosses 2 MB the symptom is the same log
line; add it to LARGE_CATEGORIES.
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
memory/wiki-reference-page-sizes.md), so every render callinggetCategoryBundle('item')/getCategoryBundle('vehicle')loggedFailed to set Next.js data cache for … items over 2MB can not be cached (3441446 bytes)and silently failed the cache write.kbCacheOptsnow takes the category as an optional arg and returnscache: 'no-store'for the known-large set (LARGE_CATEGORIES = { item, vehicle }). Other categories (weapon,location) keep the 1hrevalidate.STARSTATS_DISABLE_FETCH_CACHE=1still wins globally for the Playwright scenario-isolation path.If a third category ever crosses 2 MB the symptom is the same log line — add it to
LARGE_CATEGORIES.Test plan
pnpm --filter web run test:run— 30 tests pass (6 new inreference.test.ts: large-category set membership, revalidate default + small categories, no-store for large categories,STARSTATS_DISABLE_FETCH_CACHEglobal override)pnpm --filter web run typecheck— cleanpnpm --filter web run lint— no new warnings (3 pre-existing remain in unrelated files)/v1/reference/itemand/v1/reference/vehiclerequests.