nextjs - ✅(Solved) Fix Docs: Caching (`cacheComponents: true`) does not mention that it does not work by default with serverless functions [1 pull requests, 3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#91959Fetched 2026-04-08 01:35:30
View on GitHub
Comments
3
Participants
3
Timeline
9
Reactions
0
Author
Assignees
Timeline (top)
commented ×3assigned ×1closed ×1cross-referenced ×1

PR fix notes

PR #92232: docs: clarify serverless runtime behavior for use cache

Description (problem / solution / changelog)

Summary

  • add a prominent note in the App Router Caching guide about runtime behavior on serverless deployments
  • clarify that use cache runtime entries are in-memory and may not persist across requests when requests hit different instances
  • link directly to use cache: remote as the durable/shared runtime caching option

Closes #91959

Verification

Notes

  • Formatting toolchain was not run in this environment because pnpm is unavailable on host (pnpm: not found).
  • Change is a minimal docs-only edit (single file, two inserted lines in a callout block).

Changed files

  • docs/01-app/01-getting-started/08-caching.mdx (modified, +2/-0)
  • docs/01-app/01-getting-started/09-revalidating.mdx (modified, +2/-0)
  • docs/01-app/03-api-reference/01-directives/use-cache.mdx (modified, +3/-1)
RAW_BUFFERClick to expand / collapse

What is the documentation issue?

Vercel runs Next.js on serverless functions. Each incoming request may spin up a new function instance with a fresh in-memory LRU cache. So even though 'use cache' stores results in memory, that memory doesn't survive between instances.

There is no mention on this in the docs when using cacheComponents.

Afaik, the old fetch() + next: { revalidate } ISR approach used Vercel's external Data Cache infrastructure which does persist across instances. 'use cache' doesn't use that by default.

Is there any context that might help us understand?

https://nextjs.org/docs/app/api-reference/directives/use-cache-remote seems to be one solution. But I feel this should be prominently explaind and lifted in other docs as most users will run into this when using Cache Components. https://nextjs.org/docs/app/getting-started/caching especially should at least have a reference to the remote cache docs and a note.

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/app/getting-started/caching

extent analysis

Fix Plan

To address the issue of the LRU cache not persisting between serverless function instances on Vercel, we can utilize the use cache: 'remote' directive.

Steps to Implement the Fix

  • Update the next.config.js file to include the use cache: 'remote' directive for the specific components that require caching.
  • Use the use-cache-remote directive in your Next.js components to enable remote caching.

Example Code

// Import the use-cache-remote directive
import { useCache } from 'next/app';

// Enable remote caching for a component
export default function MyComponent() {
  useCache('remote');
  // Component code here
}

Verification

To verify that the fix is working, you can test your application on Vercel and check the cache behavior between different serverless function instances.

Extra Tips

  • Make sure to update your Next.js version to the latest to ensure compatibility with the use cache: 'remote' directive.
  • Refer to the Next.js documentation for more information on using remote caching with use-cache-remote.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING