'use cache'
A Next.js directive that caches the result of a function, component or whole route, with its arguments forming the cache key.
In more detail
In Next.js 15 it is experimental and needs the dynamicIO or useCache flag in next.config. Set the lifetime with cacheLife and labels with cacheTag. Later versions made it the main caching model under the cacheComponents option.
Related terms
- cacheLife — A Next.js function used inside use cache that sets how long the result stays fresh, when it revalidates and when it expires.
- Dynamic IO — An experimental Next.js 15 mode in which data access is dynamic by default and you opt into caching with use cache.
- directive — A string written at the top of a file or function, such as 'use client', that tells React or Next.js how to treat that code.
Taught in
- Revalidation Strategies: revalidatePath & Cache Life — Next.js 15 & Modern App Router Architecture