Real World Example

Caching an E-commerce Catalogue

Large shops like Amazon and Nykaa serve product pages from caches and only invalidate when something changes. A practical ShopEase setup:

PageStrategy
/ homerevalidate = 300 (5 min)
/products/[id]force-cache + tag product-<id>, revalidated when admin saves
/category/[slug]revalidate 60 s + tag category-<slug>
/cart, /accountDynamic (reads cookies)
Stock badge on product pageSmall client fetch or a dynamic Suspense part

Admin Saves a Product

// app/admin/products/actions.ts
'use server';

import { revalidateTag } from 'next/cache';
import { prisma } from '@/lib/prisma';
import { requireAdmin } from '@/lib/auth';

export async function saveProduct(id: number, data: { name: string; price: number; categorySlug: string }) {
  await requireAdmin();
  await prisma.product.update({ where: { id }, data: { name: data.name, price: data.price } });
  revalidateTag('product-' + id);
  revalidateTag('category-' + data.categorySlug);
}

Tip: Tag by entity (product-42) and by list (category-mobiles). Then one save refreshes exactly the pages that show that product.