Skip to main content
Our new developer certification is live!

Cache Priming

This project updates launch.json before builds to prime the cache with all content URLs that are marked for sitemap inclusion. The list is generated from Contentstack entries and written to the cache.cachePriming.urls array.

How It Works

  • The updateLaunchConfig.mjs script queries Contentstack for page, blogpost, guide, live_stream, and person entries.
  • Only entries with metadata.include_in_sitemap === true are included.
  • Existing launch.json settings are preserved; only cache.cachePriming.urls is overwritten.

When It Runs

The script runs automatically during npm run build via the prebuild hook:

npm run prebuild

Required Environment Variables

The script is skipped if any required values are missing:

  • NEXT_PUBLIC_CONTENTSTACK_API_KEY
  • NEXT_PUBLIC_CONTENTSTACK_DELIVERY_TOKEN
  • NEXT_PUBLIC_CONTENTSTACK_ENVIRONMENT

The script loads .env files using @next/env, so the same environment file setup that works for next build will be picked up here. If the required values are still unset, the build continues and launch.json is not modified.