← All posts
Platform
Purging by cache tag at 150 ms worldwide
Cache tags let publishers purge every page that mentions an article in one call. Making that fast across 38 locations meant rethinking how we index cached objects.
Purging by URL is easy: hash the URL, find the object, delete it. Purging by tag is harder, because one tag can point to thousands of objects spread across every location.
An index per location
Each location keeps a compact index from tag to object keys, updated as objects enter and leave the cache. We store it in memory as a roaring bitmap per tag, which keeps even popular tags small.
Fan-out
A purge request is written once to a replicated log. Every location subscribes and applies purges in order. The 150 ms figure is the 95th percentile from API call to the last location confirming.
What we learned
- Bounding the number of tags per object (we allow 64) keeps the index predictable.
- Ordering matters: a purge must never overtake the write that it is supposed to remove.