Data Fetching — 4 fetch Cache Policies + revalidate
Data Fetching — 4 fetch Cache Policies + revalidate
💡 Why Does This Matter? — Cache Policy Determines Page Speed
4 fetch Cache Policies + How to Revalidate
1. Default — force-cache (SSG)
Fast, but changes to the data won't be reflected. Best suited for data that rarely changes.
2. no-store (SSR)
Always up to date. Use for per-user data, live prices, or inventory where freshness on every request matters.
3. revalidate (ISR — Incremental Static Regeneration)
Combines the speed of caching with freshness. Ideal for blogs, docs, and content that updates occasionally.
4. tags + revalidateTag (On-Demand Invalidation)
Perfect for on-demand updates (e.g., immediately after publishing a post). ISR + tags is the standard production combination.
5. Path-Level Invalidation — revalidatePath
6. Summary — When to Use What
💡 💡 Next.js Data Fetching: 5 Practical Tips
1. force-cache is the default — data is cached unless you say otherwise
Fetches at build time and caches permanently. The number-one reason you don't see updated data.
2. Heuristics for choosing a revalidate interval
- ▸Content changes less than once per minute → 60
- ▸Changes a few times per hour → 300
- ▸Rarely changes → 3600 or more, or forever (force-cache + tags)
3. Combining tags with revalidateTag is the most powerful approach
A single revalidateTag('posts') call in a create/update/delete action invalidates all related caches.
4. Same URL is auto-deduplicated — no need to worry about call count
Even if multiple components call fetch('/api/me') within the same render, only one actual network request is made.
5. Calling cookies() or headers() forces the route to be dynamic
The page switches to dynamic mode regardless of the fetch cache setting.