Prompt
How do I keep programmatic pages updated when source data changes
Latest observation
To keep programmatic pages updated when source data changes, the usual goal is to separate page generation from page freshness and make regeneration automatic.
Here are the main approaches:
1. Regenerate pages on a schedule
If your data changes periodically, rebuild pages on a cron schedule.
- Simple to set up
- Good for content that doesn’t need instant updates
- Example: rebuild every hour, every night, etc.
2. Regenerate when source data changes
Best option if you control the data pipeline.
Typical flow:
- Source data changes
- A webhook/event is triggered
- Your system regenerates only the affected pages
- Pages are republished
This is often done with:
- webhooks
- message queues
- CI/CD triggers
- build pipelines
3. Use on-demand revalidation / incremental static regeneration
If you’re using a framework like Next.js, Nuxt, or similar, you can:
- serve static pages
- refresh them in the background when data becomes stale
- revalidate specific routes or pages only when needed
This gives a good balance of speed and freshness.
4. Fetch data at request time
Instead of baking the data into the page at build time, fetch it dynamically on each request or via API.
- Always fresh
- More backend load
- Can be slower than static pages
Good for:
- highly dynamic content
- dashboards
- inventory/pricing
- user-specific data
5. Use a CMS or data layer with preview/live sync
If content comes from a CMS, use:
- webhooks from the CMS
- draft/preview modes
- cache invalidation when content is published
6. Add cache invalidation
Even if pages are generated dynamically or cached by a CDN, make sure you invalidate:
- the page cache
- any API cache
- search indexes
- derived data caches
Otherwise the source updates won’t appear.
Recommended pattern
For most programmatic content sites, the best setup is:
- Static generation for performance
- Webhook-driven revalidation for freshness
- Fallback to scheduled rebuilds
- Manual revalidation for critical fixes
Example architecture
- Source data in a database or CMS
- Change event triggers a webhook
- Webhook calls your app
- App revalidates affected routes
- CDN cache is purged
- Users see updated pages
If you want, I can also show:
- a Next.js example,
- a generic architecture diagram, or
- the best approach for your stack.