This data is cached and updates when revalidated
1234
Total Views
Invalid Date
Last Updated
Invalid Date
Fetched At
Each button increments views and revalidates using a different method
| Method | Scope | Use Case |
|---|---|---|
| revalidatePath(path) | Single route or layout subtree | After form submission on specific page |
| revalidateTag(tag) | All fetches with matching tag | CMS webhook, cross-page data updates |
| { next: { revalidate: 60 } } | Individual fetch request | Time-based freshness (ISR pattern) |
'use server';
import { revalidatePath } from 'next/cache';
export async function updateProduct(
id: string,
data: ProductData
) {
await db.product.update(id, data);
// Revalidate the product page
revalidatePath(`/products/${id}`);
}// In Server Component
const data = await fetch(url, {
next: {
tags: ['products', 'featured'],
revalidate: 3600 // 1 hour
}
});
// In Server Action
revalidateTag('products'); // All tagged fetches refreshPrefer revalidateTag over revalidatePath for data that appears on multiple pages. Tags give you fine-grained control over which cached data to invalidate without knowing all the routes that use it.