How do you execute a global CDN cache invalidation for a critical security patch without melting your origin servers under a thundering herd?
A cynical look at global cache invalidation, the necessity of origin shielding, and why relying on manual purges is an architectural anti-pattern. Use this distributed systems answer to show the decision, trade-off, and evidence rather than a memorised definition. It also connects caching to the point an interviewer is testing.
What the interviewer is scoring
- Whether they understand the thundering herd problem and how to mitigate it.
- Does the candidate utilise cache busting and versioning strategies effectively.
- That they evaluate the latency differences between purge and ban operations.
- Whether the candidate can design a hierarchical caching tier using origin shields.
- Whether they consider the implications of eventual consistency in global cache synchronisation.
Answer
Short answer
A cynical look at global cache invalidation, the necessity of origin shielding, and why relying on manual purges is an architectural anti-pattern.
Why a global purge is architectural suicide
The amateur instinct when a compromised static asset (like a core JavaScript library) is discovered across thousands of global CDN edge nodes is to issue a frantic, global "purge" command. This is architectural suicide. A naive global purge physically evicts the object from the cache across all edge locations simultaneously. When millions of concurrent users subsequently request that file, every single edge node experiences a cache miss at exactly the same time. The CDN obediently forwards thousands of identical requests directly to the backend infrastructure. This instantaneous traffic spike—the thundering herd—will immediately DDoS the origin servers, turning a security incident into a catastrophic platform outage.
Furthermore, iterating through massive directories to find specific files is computationally expensive for the CDN control plane. A purge command is a brute-force approach to a nuanced problem.
The necessity of origin shielding
To survive cache invalidation at scale, a hierarchical caching architecture is mandatory. A dedicated tier of high-capacity cache servers—an origin shield—must be positioned directly in front of the origin datacenters.
flowchart TD
A["Administrator Invalidation Request"] --> B["CDN Control Plane"]
B --> C["Edge Node (Europe)"]
B --> D["Edge Node (Asia)"]
B --> E["Edge Node (Americas)"]
C --> F["Origin Shield Cache"]
D --> F
E --> F
F --> G["Origin Server Infrastructure"]When edge nodes experience a cache miss post-invalidation, they route their requests to the origin shield rather than directly to the origin. The shield collapses these simultaneous requests, forwarding only a single fetch to the backend. Once the patched asset is retrieved, the shield streams the response back to all waiting edge nodes concurrently. Without this request collapsing mechanism, the origin is entirely exposed to the whims of edge node synchronization.
Surrogate keys and intelligent eviction
Instead of a raw purge, robust architectures utilize surrogate keys (cache tags) to group related assets logically. An invalidation request targeting a specific surrogate key allows the CDN to efficiently mark the asset as stale across all edge locations via a "ban" operation. Unlike a purge, a ban adds a rule to a blacklist, evaluating incoming requests against this list before serving the cached object, which is significantly faster and less disruptive to the CDN's internal state.
Versioning as the ultimate escape hatch
Relying on manual cache invalidation is a symptom of a flawed deployment pipeline. The only foolproof defense mechanism is immutable versioning. Instead of mutating an existing app.js file, the CI/CD pipeline must inject a cryptographic hash of the file contents into the filename (e.g., app-a9f3b2c.js).
This entirely circumvents the need for explicit CDN invalidation. The new URL represents a completely distinct asset, while the old asset naturally ages out based on its Time-To-Live (TTL). This approach eliminates the coordination problem of invalidation entirely, trading slight storage bloat for absolute deployment safety.
The grim reality of propagation delay
It is a common fallacy to treat CDN invalidation as an instantaneous atomic operation. Distributed control planes have inherent propagation delays; it takes time for an invalidation instruction to replicate to every Point of Presence (PoP) globally. During this transition window, the system is strictly eventually consistent. Backend APIs must be engineered to be fully backwards-compatible with both the old and new versions of the static assets, as users hitting different edge nodes will receive different versions of the truth until the propagation completes.
Efficient global cache invalidation relies on hierarchical origin shielding to collapse request storms, whilst immutable versioning of static assets eliminates the need for manual cache purging altogether.
© 2026 Preptima. Originally published at preptima.com.
Likely follow-ups
- How would you decide, for a given asset class, whether a surrogate-key ban is sufficient or whether you genuinely need a full purge?
- How does your design change if the compromised asset is embedded inline in thousands of already-cached HTML pages rather than being its own file?
- An engineer pushes a broken cache-control header that marks a sensitive, personalised response as publicly cacheable at the edge. How do you detect and recover?
Related questions
- Design the asset delivery and deploy strategy for a large single-page app. What happens to a user who has the tab open when you ship?hardAlso on caching and cdn6 min
- Where do you put the cache, and how big does it need to be?hardAlso on caching and cdn6 min
- A popular key expires and forty thousand requests reach the database in the same second. What do you change?hardAlso on caching5 min
- A user's access to a document set is revoked. What has to happen across your RAG stack?hardAlso on caching6 min