← All posts
Edge Caching at Scale with Cache Tags
Caching is easy. Invalidation is the hard part. Cache tags let us purge exactly what changed and nothing more.
We cache aggressively at the edge. The trick was never the cache — it was purging it precisely when data changed.
Tag, then purge by tag
Attach tags to a response, then invalidate by tag when the underlying data mutates:
res.setHeader("Cache-Tag", "product-42,catalog");
// later, when product 42 changes:
await purgeByTag("product-42");The goal is to purge exactly what changed. Purge too much and you've built a slow uncached site with extra steps.
More to read