Skip to content

Docs: Caching (cacheComponents: true) does not mention that it does not work by default with serverless functions #91959

@thernstig

Description

@thernstig

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

Metadata

Metadata

Assignees

Labels

No fields configured for Documentation.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions