On-demand revalidation cho phép invalidate cache và regenerate pages ngay lập tức thay vì đợi timeout.
- Pages Router:
res.revalidate('/path')trong API route. - App Router:
revalidatePath('/path')hoặcrevalidateTag('posts')trong Server Action hoặc Route Handler.
Phù hợp khi CMS webhook trigger cần update content ngay.
On-demand revalidation lets you invalidate the cache and regenerate pages immediately rather than waiting for a timer.
- Pages Router: call
res.revalidate('/path')inside an API route. - App Router: call
revalidatePath('/path')orrevalidateTag('posts')inside a Server Action or Route Handler.
Ideal when a CMS webhook fires and content needs to update right away.