Quick revision
The short answer
We make every page a shared object by moving the personalised modules out of the HTML into a separate client-side call, then serve those pages from the CDN with a short freshness of about 30 seconds plus stale-while-revalidate, request collapsing and an origin shield, so the origin sees roughly one revalidation per object per TTL instead of one request per reader. Updates reach readers in seconds through surrogate-key purges fired by the newsroom system, and stale-if-error plus static fallback pages protect us if the origin struggles.
What to remember
In this answer, we designed edge caching for a news site at 200,000 requests per second. We made pages shared by moving personalised modules into a private call, served them with s-maxage=30, stale-while-revalidate and stale-if-error, used request collapsing and an origin shield so origin load becomes objects divided by TTL, and purged by surrogate key on every edit. The arithmetic gave a few hundred renders per second against 3,000, confirmed by load tests with purge bursts and backed by a static fallback mode.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
We make every page a shared object by moving the personalised modules out of the HTML into a separate client-side call, then serve those pages from the CDN with a short freshness of about 30 seconds plus stale-while-revalidate, request collapsing and an origin shield, so the origin sees roughly one revalidation per object per TTL instead of one request per reader. Updates reach readers in seconds through surrogate-key purges fired by the newsroom system, and stale-if-error plus static fallback pages protect us if the origin struggles.
Why this question is asked
Breaking news is the classic stress test for a cache. Traffic jumps by an order of magnitude in minutes, the content keeps changing, and everyone wants to see the latest version at once. The numbers in this question make the problem sharp: 200,000 requests per second against an origin that can render 3,000, so we need well over 98 percent of requests answered at the edge, while still showing updates within half a minute. Interviewers use it to check whether we know the HTTP caching tools that make this possible and can reason about origin load with arithmetic. In this answer, we will set out the requirements and numbers, make the pages cacheable, choose the freshness headers, add an origin shield, design purging, estimate the origin load and plan for failure.
1Requirements and Rough Numbers
We have 200,000 page requests per second at peak, an origin that renders about 3,000 pages per second, and a requirement that edits appear within about 30 seconds. If the CDN served every request it could, the origin would still need to absorb all misses, so the miss rate must stay well under 3,000 / 200,000, which is 1.5 percent, with headroom for purges and bursts. We want the origin at about half its capacity at worst.
The traffic is concentrated: perhaps 2,000 articles are actively read, plus a few hundred section and home pages, and the top 20 objects take most requests. A small set of hot objects is exactly what a cache handles best, provided each object is the same for every reader.
2Making Pages Shared Instead of Personal
The home page contains a few personalised modules, such as saved stories or a greeting. If we render those into the HTML, every reader gets a different page, and either the CDN cannot cache it or the cache key must include something per user, which destroys the hit ratio. So we render the page once for an anonymous reader and fill the personal modules separately.
There are two common ways. The first is a small client-side call from the page's JavaScript to an API such as /api/me/modules, marked private and never cached at the edge; it returns a few hundred bytes of JSON rather than a full page. The second is edge-side includes (ESI), where the cached page contains placeholders and the edge fetches the personal fragments, which ties us to the CDN's ESI support, so for most news sites the client-side call is simpler. Either way, the page's cache key stays just the URL, and we never vary the page on cookies.
3Freshness Headers: Short TTL, Serve Stale While Refreshing
For articles and section pages the origin sends headers like the ones below. The s-maxage value applies to shared caches such as the CDN, while the browser gets a shorter max-age so a reader who presses refresh asks the CDN again.
Notice what stale-while-revalidate buys us. Without it, when the 30 seconds run out, the next readers wait while the CDN fetches a new copy, and on a hot page thousands of readers arrive in that moment. With it, readers keep getting the slightly old page instantly, and a single background request refreshes it. The reader-visible delay of an update is therefore at most about 30 seconds plus the refresh time, which meets the target.
The second protection is request collapsing, which most CDNs offer as a setting. When many requests for the same object miss at the same moment, the edge sends only one to the origin and makes the others wait for that response. Combined with stale-while-revalidate, a hot object produces one origin request per refresh no matter how many people read it.
4An Origin Shield in Front of the Origin
A CDN has many edge locations, sometimes hundreds, and each refreshes each object independently, so a page with a 30-second TTL could be fetched by 200 locations every 30 seconds. An origin shield is a designated mid-tier cache that all edges ask on a miss; it collapses their requests, and only the shield talks to the origin.
- Browsermax-age=10; personal modules from a private API call
- CDN edge locationshundreds of locations; collapse requests, serve stale while refreshing
- Origin shieldone mid-tier cache; all edge misses meet here
- Origin renderersabout 3,000 pages per second; target under 1,500
- CMS and databasenewsroom edits; publishes purge events
5 layers, from the top down. Step through them one at a time.
The shield turns many edge refreshes into one origin request per object per TTL.
So with a shield, origin load becomes roughly the number of active objects divided by the TTL, not the number of readers. That is the single most important property of this design, and it is what makes 200,000 requests per second manageable.
5Publishing Updates With Surrogate-Key Purges
A 30-second TTL is the safety net, not the main update mechanism. When an editor saves an article, the newsroom system sends a purge for the surrogate key article-48121 to the CDN API. Every cached page tagged with that key, the article itself, the politics section and the home page that lists it, is invalidated within a second or two at all locations. Most CDNs call this feature surrogate keys or cache tags.
We prefer tag purges to URL purges because one article appears on many pages, and the renderer, which adds the tags as it builds each page, always knows which. We can also use a soft purge, which marks objects stale instead of deleting them, so stale-while-revalidate still applies and the purge does not cause a burst of blocking misses.
6Estimating Origin Load
Now we can do the arithmetic. Suppose 2,000 active articles and 300 listing pages, about 2,300 objects. With a shield and a 30-second TTL, routine refreshes cost about 2,300 / 30, which is roughly 77 renders per second. During a busy story the newsroom might publish 5 edits per second across all stories, and each edit purges the article plus perhaps 10 listing pages, which adds about 55 renders per second. Adding a few hundred per second for the long tail of old articles, the origin stays far below 3,000.
| Source | Calculation | Renders per second |
|---|---|---|
| Routine refresh of hot objects | 2,300 objects / 30 s TTL | about 77 |
| Purges from edits | 5 edits/s x 11 pages each | about 55 |
| Long tail of cold articles | misses at the shield | about 200 to 400 |
| Without a shield | 77 x 200 edge locations | about 15,000 |
| Origin capacity | measured | 3,000 |
7Load Testing and a Degraded Mode
Estimates are not proof. We load test the origin at the expected shielded miss rate, and we include a burst of purges, such as a home page rebuild that purges everything tagged home at once, because that is when load spikes.
Finally, we prepare for the origin saturating anyway. stale-if-error keeps old pages flowing if the origin returns errors, and a degraded mode lets the newsroom publish a static fallback page for the biggest story to object storage such as S3, served by the CDN without the renderers, and temporarily raise s-maxage on listing pages.
8Follow-up questions
How would you estimate origin load from the number of active articles?
Count the distinct cacheable objects, which is active articles plus listing pages and their variants, then divide by the TTL to get the refresh rate when a shield and request collapsing are in place. Add purge-driven renders, which are edits per second times the number of pages each edit invalidates, and add the cold-object miss rate taken from logs of a previous peak. Without a shield, multiply the refresh rate by the number of edge locations that see each object. Then compare the total with measured origin capacity and keep at least a factor of two of headroom.
9Conclusion
In this answer, we designed edge caching for a news site at 200,000 requests per second. We made pages shared by moving personalised modules into a private call, served them with s-maxage=30, stale-while-revalidate and stale-if-error, used request collapsing and an origin shield so origin load becomes objects divided by TTL, and purged by surrogate key on every edit. The arithmetic gave a few hundred renders per second against 3,000, confirmed by load tests with purge bursts and backed by a static fallback mode.
Open with
The key is to make origin load depend on the number of objects, not the number of readers. First I make pages shared: render the anonymous page once and load the personalised modules with a separate private API call, so the cache key is just the URL.
Then, if they want more
The origin sends public, s-maxage=30, stale-while-revalidate=60 and stale-if-error, so readers always get an instant response and one background request refreshes each page.
With request collapsing and an origin shield, origin load is roughly active objects divided by TTL, so about 2,300 hot objects cost under 100 renders a second against a capacity of 3,000; without the shield it would be multiplied by the number of edge locations. For updates I would not rely on the TTL.
The renderer tags pages with surrogate keys for the articles they show, and the newsroom system sends a soft purge by tag on every edit, so changes appear everywhere in a second or two. Finally I load test at the shielded miss rate including purge bursts, and keep static fallback pages in object storage in case the origin saturates.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Design the edge caching so the origin stays within its capacity while updates appear...": https://scrivio-interview-library.netlify.app/architecture/caching-strategies/c84ac522f0/