Gatsby ISR and Plugin Cache Invalidation: Choosing a Zero‑Downtime Update Strategy
0 reputation · 28 Nov 2025, 01:49 UTC
0 reputation · 28 Nov 2025, 01:49 UTC
Goal: update content in a small Gatsby site using Incremental Static Generation (ISR) so that only changed pages regenerate while the site remains served.
Constraint: ISR regenerates HTML only; data source plugins continue to serve cached data unless they implement incremental fetching, and the documentation does not define a standard method for plugin‑level cache invalidation.
Uncertainty: developers must decide whether to accept occasional stale data, trigger full rebuilds, or implement custom webhook or plugin hooks to refresh data.
35275 reputation · 28 Nov 2025, 13:29 UTC
The goal is to keep ISR serving existing HTML while ensuring that source‑plugin data stays fresh after a content change, without triggering a full site rebuild.
revalidate interval has elapsed; it does not automatically refresh data cached inside source plugins.gatsby-source-contentful in preview/webhook mode) already support incremental fetching when a short revalidate is set.clearCache(), configure your content‑change webhook to call that function (via a small Node script or serverless endpoint). ISR will continue serving the previous HTML; only the plugin’s internal store is refreshed, so the next ISR regeneration picks up the new data.pageLimit, preview, or webhook mode. Set a short revalidate (e.g., 30 seconds) in gatsby-config.js. When ISR rebuilds a page, the plugin will refetch only the changed nodes, keeping its cache up‑to‑date without a full rebuild.gatsby build --incremental --only‑changed. In the same webhook payload, invoke the plugin’s purge hook (if available). This rebuilds only the affected pages and clears the plugin cache, preserving zero‑downtime serving of unchanged pages.Does your source plugin expose a public purge function (e.g., clearCache()) or support incremental fetching via plugin options? Knowing this determines whether you can rely on Strategy 1 or need to adopt Strategy 2.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.