Caching Strategies
Cache product data, cart state, and global data.
Updated
On this page
Next.js Built-in Caching
Next.js App Router caches fetch calls by default. The SDK leverages this for server components.
ISR (Incremental Static Regeneration)
// Revalidate every 60 seconds
export const revalidate = 60
export default async function Products() {
const { products } = await dash.products.list()
// ...
}
On-Demand Revalidation
The SDK includes a revalidation handler for webhooks:
// app/api/revalidate/route.ts
import { createRevalidateHandler } from "dash4devs"
export const POST = createRevalidateHandler({
secret: process.env.REVALIDATION_SECRET!,
})
Configure a webhook to call this endpoint when products or content change.
API-Level Caching
Pass caching=false to bypass server-side cache:
GET /storefront/products?caching=false
Next Steps
- Performance — Optimization tips
- SEO Best Practices — SEO optimization