Cache and Revalidation Matrix
Pack:
nextjsParent skill: Next.js Data Fetching and Cache Source:nextjs/nextjs-data-fetching-and-cache/references/cache-and-revalidation-matrix.md
Choose by data shape
Section titled “Choose by data shape”- Public, shared, and slow-changing data:
- cache it deliberately
- prefer route or tag invalidation over ad hoc busting
- User-specific or request-authenticated data:
- default to dynamic or private handling
- avoid public cache assumptions
- Derived or aggregated data reused across routes:
- consider
unstable_cacheor tagged fetches
- consider
Primitive selection
Section titled “Primitive selection”- Plain
fetch(...):- default starting point for most App Router reads
fetch(..., { next: { revalidate, tags } }):- use when stale-while-revalidate or tag-based invalidation is enough
revalidatePath(path):- use after a mutation when a concrete route tree should refresh
revalidateTag(tag)orupdateTag(tag):- use when multiple routes depend on the same data slice
unstable_cache(...):- use for non-
fetchasync work or shared computed reads
- use for non-
Common mistakes
Section titled “Common mistakes”- Caching tenant or user data as if it were public
- Invalidating a path when the real coupling is data-wide
- Creating many unrelated tags with no ownership model
- Mixing Pages Router guidance into App Router code