← Lessons

quiz vs the machine

Gold1410

System Design

The Purge and Invalidation

How to remove or refresh stale content across many edge caches.

5 min read · core · beat Gold to climb

Why purge exists

TTLs expire content eventually, but sometimes you must remove it now, such as a wrong price or a takedown. Purge and invalidation force the CDN to discard or refresh a cached object before its TTL ends.

Targeting what to clear

  • Single object purge clears one exact URL.
  • Prefix or wildcard purge clears a path tree at once.
  • Tag based purge clears every object stamped with a surrogate tag, useful when one change touches many URLs.

Hard versus soft

  • Hard purge deletes the object so the next request is a miss and refill.
  • Soft purge marks it stale so the edge can serve it while it revalidates, avoiding a sudden origin spike.

Propagation reality

A purge must reach every PoP, which takes time. Designers prefer versioned URLs, where changing the asset name sidesteps purge entirely. Reserve purge for content whose URL cannot change.

Key idea

Purge removes or refreshes cached content before TTL, by URL, prefix, or tag, while versioned URLs avoid the need to purge at all.

Check yourself

Answer to earn rating on the learn ladder.

1. What is a tag based purge useful for?

2. What does a soft purge do?

3. Why are versioned URLs often preferred over purging?