Cache Priming
This project updates launch.json before builds to prime the cache with up to
50 content URLs (Launch's limit per deployment) 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.mjsscript queries Contentstack forpage,blogpost,guide,kickstart,live_stream, andpersonentries. - Only entries with
metadata.include_in_sitemap === trueare included. - URLs are picked in priority order until the 50-URL cap (
MAX_PRIMED_URLS) is reached:/and/index.md, pages, guide overviews, kickstarts, blog posts (newestdatefirst), then guide chapters, live streams and person pages. - The final list is sorted alphabetically so diffs stay stable.
/index.mdis always included so homepage markdown is primed separately from HTML/. Accept negotiation at the Launch edge rewrites markdown/to/index.mdbefore the cache lookup, so the primed HTML object is not reused.- Existing
launch.jsonsettings are preserved; onlycache.cachePriming.urlsis overwritten.
When It Runs
The script runs automatically during npm run build via the prebuild hook:
npm run prebuildRequired Environment Variables
The script is skipped if any required values are missing:
NEXT_PUBLIC_CONTENTSTACK_API_KEYNEXT_PUBLIC_CONTENTSTACK_DELIVERY_TOKENNEXT_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.