cacheLife
A Next.js function used inside use cache that sets how long the result stays fresh, when it revalidates and when it expires.
In more detail
Built-in profiles are default, seconds, minutes, hours, days, weeks and max, and you can define your own in next.config. Each profile has stale, revalidate and expire times.
Example
'use cache';
cacheLife('hours');Related terms
- 'use cache' — A Next.js directive that caches the result of a function, component or whole route, with its arguments forming the cache key.
- revalidation — Refreshing cached data or pages so they show new content, either after a time limit or on demand.
Taught in
- Router Cache: In-Memory Client Prefetch Semantics — Next.js 15 & Modern App Router Architecture
- Revalidation Strategies: revalidatePath & Cache Life — Next.js 15 & Modern App Router Architecture