Skip to main content

Why cache invalidation matters

ButterCMS uses a content delivery network (CDN) infrastructure to provide content faster. If you request data from Europe and the server is in the United States, you will get the content from one of the cache servers in Europe instead of the original one.

The cache staleness problem

Benefits of webhook-based invalidation

CDN cache invalidation

Cloudflare

Purge Cloudflare cache when ButterCMS content changes:

Fastly

AWS CloudFront

Application-level cache invalidation

Redis cache

Memcached

In-memory cache (Node.js)

Static site rebuilds

For static site generators (Next.js, Astro, Hugo), trigger a rebuild when content changes:

Vercel deploy hooks

Netlify build hooks

Next.js on-demand ISR

For Next.js apps using Incremental Static Regeneration:

Smart cache invalidation strategies

Tag-based invalidation

Use cache tags to group related content for efficient invalidation:

Cascade invalidation

When one piece of content changes, invalidate related content:

Debounced invalidation

Prevent excessive cache clears during bulk content updates: