Caching and Performance for Contentstack Sites

The fastest request is the one you don't make

Contentstack's Delivery API is served from a CDN and is fast. But calling it on every page view, with deep references and huge payloads, still slows you down and can hit rate limits. A good caching strategy fixes that.

Layers of Caching

  1. Contentstack CDN — API responses cached globally
  2. Your framework — static generation, ISR, or data cache
  3. Your hosting CDN — cached HTML at the edge
  4. Browser — cached static assets

Static and Incremental

  • SSG for pages that rarely change
  • ISR / on-demand revalidation — regenerate a page when content is published
// Next.js route handler for a publish webhook
import { revalidatePath } from 'next/cache';

export async function POST(req) {
  const body = await req.json();
  revalidatePath(body.data.entry.url);
  return Response.json({ revalidated: true });
}

Validate the webhook secret before revalidating.

Reduce Payloads

  • Use only / except to fetch specific fields
  • Include only needed references
  • Paginate lists
  • Use GraphQL to request exactly what the page needs

Avoid Waterfalls

Fetch independent content in parallel with Promise.all instead of one call after another.

Measure

  • Core Web Vitals (LCP, INP, CLS)
  • API response times and cache hit ratios
  • Monitor with New Relic Browser or similar tools

Cache by default, invalidate precisely on publish. That's the whole strategy.

Arivanandhan Chitheshwaran