Cache and Revalidation Patterns
What you'll learn: How framework-level caching controls when your async Server Components re-fetch data.
The Server Component Data Problem
You've learned that async Server Components can fetch data directly. But what happens when that same component renders again? Do you hit the database every single time? That could be wasteful for data that doesn't change often.
Framework-Level Caching
Modern React frameworks (especially Next.js) provide automatic caching for data fetched in Server Components. When you use fetch() inside an async component, the framework can cache the result:
// This fetch is cached by default in Next.js
async function ProductList() {
const res = await fetch('https://api.example.com/products');
const products = await res.json();
return <div>{/* render products */}</div>;
}
The framework remembers this response. If another Server Component requests the same URL during the same render pass, it returns the cached data instantly—no duplicate network call.
Controlling Revalidation
You control when to refresh cached data using revalidation strategies:
// Cache for 60 seconds, then revalidate
fetch(url, { next: { revalidate: 60 } });
// Never cache (always fresh)
fetch(url, { cache: 'no-store' });
// Cache indefinitely until manually invalidated
fetch(url, { cache: 'force-cache' });
Think of it like a refrigerator: you store food (data) so you don't go to the store (server) every time you're hungry (component renders), but eventually you need fresh groceries.
Key Takeaway: Framework-level caching for fetch() in Server Components prevents redundant requests, and revalidation options let you control when data is considered stale and needs refreshing.