Skip to content

docs: cacheMaxMemorySize: 0 is optional, not a multi-instance requirement - #38

Merged
leejpsd merged 1 commit into
mainfrom
docs/cache-max-memory-size-wording
Dec 3, 2026
Merged

leejpsd merged 1 commit into
mainfrom
docs/cache-max-memory-size-wording

Conversation

@leejpsd

@leejpsd leejpsd commented Dec 3, 2026

Copy link
Copy Markdown
Owner

What

cacheMaxMemorySize: 0 was described as "required for multi-instance correctness" in the README checklist and quick start, AGENTS.md, the agent skill, setup-instructions/setup.md and the init CLI output. It is optional. The wording now says so and explains what the option actually does.

Why (Next.js 16.2.4 source)

  • server/lib/incremental-cache/index.js 100–110: with a custom cacheHandler, maxMemoryCacheSize is only forwarded to the handler's constructor. Next keeps no in-memory ISR cache of its own in that case; the LRU lives inside FileSystemCache (file-system-cache.js 29–34), which is not used when a custom handler is configured.
  • This handler never reads ctx.maxMemoryCacheSize (no reference in src/).
  • The only other consumer is the built-in 'use cache' store: server/use-cache/handlers.js initializeCacheHandlers(cacheMaxMemorySize) → createDefaultCacheHandler(maxSize). Configuring cacheHandlers.default (the recommended wiring) replaces it (next-server.js 581–590).

So keeping 0 is harmless and matches Next's self-hosting docs, but it was never what made multi-instance reads consistent. The troubleshooting row that listed "cacheMaxMemorySize not 0" as a cause of cross-instance misses now lists only namespace/prefix mismatch.

Changes

  • README quick start comment and Production checklist item
  • AGENTS.md hard rule 2
  • skills/nextjs-redis-cache/SKILL.md: wiring comment, checklist item, troubleshooting row
  • setup-instructions/setup.md comment
  • src/cli/index.ts: init output comment (tests/unit/cli.test.ts still passes; it checks the key, not the comment)
  • changeset: patch

No runtime behavior changes.

…ment

With a custom cacheHandler, Next keeps no in-memory ISR cache of its own: the
value is passed to the handler's constructor (incremental-cache/index.js) and
this handler never reads it. It only sizes Next's built-in 'use cache' store
(use-cache/handlers.js initializeCacheHandlers), which cacheHandlers.default
replaces. README, AGENTS.md, the skill, setup.md and the init output said it
was required for multi-instance correctness; they now say it is optional and
why. The troubleshooting row that listed it as a cause of cross-instance
misses drops that cause.
@leejpsd
leejpsd merged commit dd948e0 into main Dec 3, 2026
5 checks passed
@leejpsd
leejpsd deleted the docs/cache-max-memory-size-wording branch December 3, 2026 15:09
@github-actions github-actions Bot mentioned this pull request Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant