Next.js 16 Cache Components

Demonstrating ISR and SSR using the 'use cache' directive, cacheLife, and cacheTag

Configuration

This example uses a single config flag to enable cache components:

// next.config.ts
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  cacheComponents: true,
};

On-Demand Revalidation

Invalidate cached data by tag via the API endpoint:

# Revalidate a specific product
GET /api/revalidate?tag=product-1

# Revalidate all products
GET /api/revalidate?tag=products

# Revalidate categories
GET /api/revalidate?tag=categories