Incremental Static Regeneration in Next.js: Update Static Pages on Demand
Incremental Static Regeneration (ISR) lets Next.js sites update static pages on demand. Learn how to set up ISR, verify it works, and balance freshness with performance in this practical guide.
07 Sept 2026, 09:18 UTC

Why ISR Matters
Static sites give blazing‑fast performance, but they can feel rigid when content changes. Incremental Static Regeneration (ISR) lets you keep the speed of static pages while still refreshing data after a set interval, without rebuilding the entire site. This is especially useful for blogs, e‑commerce catalogs, or any content that changes frequently but doesn’t need real‑time updates.
How ISR Works Under the Hood
When you export a page with getStaticProps and include a revalidate field, Next.js records the interval (in seconds) in the build output. At runtime, the CDN serves the cached HTML. If the cached version is older than the revalidation window, Next.js triggers a background rebuild:
- Client requests the page.
- CDN returns the old static HTML immediately.
- Next.js starts a regeneration job on the server.
- When the job finishes, the new HTML replaces the old one in the CDN cache.
- Subsequent requests receive the fresh content.
This process guarantees zero downtime and keeps users on the fastest path while the page updates in the background.
Setting Up ISR in a Next.js Project
Below is a minimal example that demonstrates ISR. Replace fetchData() with your real data source.
// pages/posts/[slug].js
import { fetchData } from '../lib/api';
export async function getStaticProps({ params }) {
const post = await fetchData(params.slug);
return {
props: { post },
// Re‑generate the page every 60 seconds
revalidate: 60,
};
}
export async function getStaticPaths() {
const slugs = await fetchAllSlugs();
return {
paths: slugs.map((s) => ({ params: { slug: s } })),
// Use blocking fallback to allow ISR on dynamic routes
fallback: 'blocking',
};
}
export default function Post({ post }) {
return {/* render post */};
}
Deploy this to a platform that supports Next.js edge functions (Vercel, Netlify, Render). The revalidate: 60 line tells Next.js to re‑build the page in the background after 60 seconds of the last request.
Verifying ISR in Production
To confirm ISR is working, follow these steps after deployment:
- Open the page in a browser.
- Change the underlying data (e.g., edit the markdown file or update the API).
- Wait for the revalidation interval (60 s in the example).
- Refresh the page; the new content should appear.
Diagnostics:
- Check the
x-nextjs-revalidateheader in the response. It should show the timestamp of the last regeneration. - Look at the build logs in your hosting dashboard; a background regeneration entry should appear after the interval.
- Inspect the CDN cache (if available) to see the updated ETag or last‑modified values.
Common Pitfalls and Trade‑offs
| Pitfall | Impact | Mitigation |
|---|---|---|
Setting revalidate: 0 | Disables ISR; page never updates automatically. | Use a positive integer for the interval. |
| Too short an interval | Increased background build load and potential CDN cache churn. | Choose a value that balances freshness with load (e.g., 60–300 s). |
| Missing caching headers | Browsers or CDNs may serve stale content longer than intended. | Let Next.js set headers automatically; avoid overriding Cache-Control unless necessary. |
| Concurrent requests triggering regeneration | First request may wait for the build to finish. | Next.js queues regeneration; consider using fallback: 'blocking' for dynamic routes to avoid extra latency. |
| Hosting provider not supporting edge functions | ISR falls back to full rebuilds or is unsupported. | Deploy to a provider that honors Next.js build outputs (Vercel, Netlify). |
Choosing the Right Revalidation Interval
There is no one‑size‑fits‑all number. Consider:
- Content volatility: News sites may need 5–15 s, while product catalogs can be hourly.
- Traffic patterns: High‑traffic pages benefit from more frequent updates to reduce stale reads.
- Build time: Longer regeneration times increase cost and latency; monitor logs to catch slow builds.
- SEO impact: Search engines may cache pages; a shorter interval can help index fresh content faster.
A practical strategy is to start with a conservative interval (e.g., 120 s) and adjust based on observed staleness and server load.
Actionable Takeaways
- Wrap your
getStaticPropswith arevalidatevalue that reflects how often the data changes. - Deploy to a Next.js‑compatible host and verify the
x-nextjs-revalidateheader. - Monitor regeneration logs to spot slow builds or failures.
- Use
fallback: 'blocking'on dynamic routes to keep ISR working while avoiding race conditions. - Adjust the interval based on real‑world metrics: user reports of stale content, build queue times, and CDN cache hit ratios.
With ISR, you get the best of both worlds—static performance and dynamic freshness—without the overhead of full rebuilds.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.