Segment revalidate, generateStaticParams для hot paths, on-demand revalidatePath/revalidateTag из mutation.
Пример
// app/blog/[slug]/page.tsx// Pre-render the top posts at build; render the long tail on first hit.exportconst revalidate = 3600; // regenerate at most once per hourexportconst dynamicParams = true; // allow slugs not in generateStaticParamsexportasyncfunctiongenerateStaticParams() {
const posts = awaitgetTopPosts(); // only the hot paths at build timereturn posts.map((p) => ({ slug: p.slug }));
}
exportdefaultasyncfunctionPost({ params }: { params: { slug: string } }) {
const post = awaitgetPost(params.slug); // cached in the Data Cache tooreturn {post.body};
}
// The correctness upgrade: on-demand invalidation from your mutation.'use server';
import { revalidateTag, revalidatePath } from'next/cache';
exportasyncfunctionpublishPost(slug: string) {
await db.publish(slug);
revalidatePath(`/blog/${slug}`); // this page is fresh NOW, not in an hourrevalidateTag('post-list'); // and any list that tagged its fetch
}
Итог
ISR code = timer + static params list + surgical invalidation on publish — stale window under your control.
Next.js: ISR (Incremental Static Regeneration) — пример кода · Sobeso