Invalidation & Rebuild
Invalidation & Rebuild
DevOps Agent Kit — documentation written for AI agents, readable by humans.
When to Rebuild
Page instances are pre-rendered at build time with slow-phase data. When that data changes (product updated, content edited), the affected instances need to be rebuilt without a full build.
jay-stack rebuild
Three targeting modes:
# By contract — rebuild all routes using this contract
jay-stack rebuild --contract product-page
# By route — rebuild all instances of a route pattern
jay-stack rebuild --route /products/[slug]
# By URL — resolve to route+params, rebuild that one instance
jay-stack rebuild --url /products/blue-widget
Narrow it down with --params:
# Rebuild one specific instance
jay-stack rebuild --contract product-page --params '{"slug":"blue-widget"}'
jay-stack rebuild --route /products/[slug] --params '{"slug":"blue-widget"}'
How it works
- Reads the route manifest to find affected routes/instances
- Re-runs slow render with fresh data
- Re-compiles server element and client bundle
- Updates the instance entry in the manifest
- Touches
build-metadata.jsonto trigger main server manifest reload - Old files are tracked in
cleanup-manifest.jsonfor later cleanup
Cleanup
After rebuilds, orphaned files (old client bundles, old server elements) accumulate. Clean them up:
jay-stack cleanup
Renderer Server
For automated invalidation, run the renderer server alongside the main server:
# Main server — pages and actions
jay-stack serve --role main --port 4000
# Renderer server — listens for webhooks, triggers rebuilds
jay-stack serve --role renderer --port 4001
The renderer server:
- Listens for data change webhooks from external systems (CMS, e-commerce)
- Determines which routes are affected (via contract name → route resolution)
- Runs
rebuildfor each affected instance - The main server detects the updated
build-metadata.jsonand reloads the manifest
Contract-based resolution
The manifest tracks which contracts each route uses. When a webhook says "product-page data changed", the renderer finds all routes that use the product-page contract and rebuilds their instances.
Build Output After Rebuild
Rebuilt instances write new files to both frontend/ and backend/:
backend/pre-rendered/— updated jay-html, cache, server elementfrontend/pages/— updated client bundle, CSS
Old files are not deleted immediately — they're tracked in cleanup-manifest.json. This avoids breaking in-flight requests that still reference old bundles.
About this document
This page is part of the Jay Stack Agent Kit — documentation generated from the framework source and written primarily for AI agents. The language and structure are optimized for machine consumption — expect precise, specification-style prose rather than narrative documentation. Learn more about the Agent Kit →