A CDN serving static assets from many edge points of presence reports a cache hit ratio of only 40%, meaning most requests still reach the object storage origin. What mechanisms would you look at to raise that ratio, and what's the role of an origin shield in this?
answer
- cache key fragmentation via query strings
- TTL too short for regional traffic volume
- origin shield = single upstream caching tier
- collapses N PoP misses into 1 origin fetch
basics
~20 sLow hit ratio usually means too many different edge locations each independently asking the origin for the same file, or the cache expiring too fast. An origin shield adds one extra caching layer between the edges and the origin so only one edge has to fetch a file the first time, and every other edge gets it from the shield instead.
solid answer
~50 sA low hit ratio points to either overly short TTLs causing frequent re-fetches, or too many PoPs each independently missing on the same popular file because request volume is fragmented across a wide geographic footprint. First checks: confirm Cache-Control TTLs are as long as content-hashing allows, and check whether query strings or headers are unnecessarily fragmenting the cache key (e.g. a random cache-buster param defeating hits). An origin shield is a single additional caching tier placed between all edge PoPs and the origin — every PoP's cache miss goes to the shield instead of origin directly, and the shield itself only misses once per object, since it aggregates traffic from all PoPs. This collapses N independent origin fetches into effectively one, protecting origin from redundant load and improving effective global hit behavior even when per-PoP hit ratio stays limited by traffic fragmentation.
go deeper
Should understand that a cache hit means served from CDN and a miss means it had to go back to the source, even without diagnosing ratios.
Should know TTL and query-string cache-key fragmentation as common causes of poor hit ratios.
Should independently propose diagnosing cache-key configuration vs traffic-volume fragmentation, and explain what an origin shield structurally does to origin load.
Should reason about shield placement trade-offs, cost/latency modeling of shield vs no-shield at a given traffic distribution, and know when a shield isn't worth the added hop (e.g. very small, single-region traffic footprints).
## What the hit ratio measures A CDN's **cache hit ratio** is the fraction of requests an edge PoP can answer from its own local cache versus how many it has to forward upstream. The mechanics behind a low ratio usually trace to one or a combination of three things. 1. **First, TTL is too short** relative to how often a given object is actually requested at a given PoP — if a file's `max-age` is 60 seconds, and a particular edge location only sees a request for that file every few minutes, the cached copy expires before it can be reused, so nearly every request looks like a fresh miss even though the content never changed. 2. **Second, the cache key itself may be broader than intended:** many CDNs default to including query strings, or sometimes specific headers/cookies, as part of the cache key. If a static asset is requested with varying query parameters — analytics tracking params, leftover cache-busting query strings, locale params that don't actually change the file bytes — each distinct combination is treated as a separate cache entry, fragmenting what should be one hot object into many cold ones. 3. **Third, geographic/traffic fragmentation:** a CDN with hundreds of PoPs spreads a site's total request volume thinly across all of them, so for anything other than the most popular handful of assets, each individual PoP may only see a trickle of requests for a given long-tail file — not enough traffic at that one location to keep the object warm before its TTL lapses, even if the TTL itself is generous. ## The diagnostic step The diagnostic step is to separate 'per-edge hit ratio is inherently capped by low regional traffic' from 'the cache key or TTL is misconfigured and we're leaving hits on the table.' The latter is fixed directly: - **normalize or strip** irrelevant query parameters from the cache key, - **extend TTLs** as far as content-hashing/versioning safely allows, - **audit** for any `Vary` header usage that's unnecessarily splitting the cache by request headers that don't actually affect the response bytes for a static file. ## What an origin shield does The former — traffic naturally too thin at any one PoP to stay warm — is what an **origin shield** addresses structurally rather than by tuning. An origin shield (CloudFront calls it Origin Shield; Akamai/Fastly have equivalent concepts) is one additional caching tier interposed between all the edge PoPs and the actual origin. Instead of every one of, say, 200 edge PoPs independently missing and fetching a popular-but-not-viral file from origin the first time a nearby user requests it — 200 separate origin fetches for the same bytes — every PoP's miss is routed to a single shield location (or a small number of them) first. The shield fetches from origin exactly once, caches it, and serves all 200 PoPs' misses from that one warm copy. This converts what would be N redundant origin round-trips (proportional to PoP count) into effectively 1, which both slashes origin load/cost and improves the effective end-to-end hit behavior, because after the first global miss, every subsequent PoP miss anywhere in the world is actually served from the shield's warm cache rather than going all the way to origin. ## The trade-off The trade-off with an origin shield is: - a small amount of added latency for the very first request that hits a cold shield (an extra network hop before reaching origin), and - additional infrastructure the CDN provider must run, sometimes at extra cost. But for any content with a long tail of moderately popular objects spread across a global footprint, that trade is almost always worth it, because origin protection and cost reduction from collapsing redundant fetches typically dwarfs the marginal latency cost on cold-shield misses, which are rare relative to total traffic once the shield warms up. ## Where it shows up A concrete manifestation of this problem shows up when a global e-commerce site pushes a product-image-heavy catalog through a CDN and finds origin request costs and load spiking during a traffic surge, even though the CDN is supposed to be absorbing traffic — investigation typically reveals the traffic is spread across dozens of edge regions each independently missing on the same set of catalog images because per-PoP traffic for any single product's image is too low to keep it warm; enabling an origin shield collapses that fan-out and both the origin bill and origin error rate drop sharply without changing a single `Cache-Control` header.
- Why would including a random analytics query parameter in a static asset's URL silently tank the CDN hit ratio?If the CDN's cache key includes the full query string by default, then /logo.png?utm=abc and /logo.png?utm=xyz are treated as two entirely distinct cached objects even though the bytes returned are identical, so no request ever reuses another request's cached copy. The fix is configuring the CDN to strip or ignore query parameters that don't affect the response body when computing the cache key.
- Does an origin shield help if the underlying problem is TTLs that are too short, rather than traffic fragmentation?Only partially — a shield reduces the number of origin round-trips per miss event by aggregating PoPs, but if the TTL is short enough that even the shield's own cached copy keeps expiring, you'll still see frequent origin fetches, just fewer of them than without a shield. The TTL problem needs to be fixed at the Cache-Control level regardless of whether a shield is in place.
- What's a downside of placing an origin shield very far (network-wise) from the origin storage?Every shield miss now has to travel that longer distance to origin, adding latency to the hopefully-rare cold-fetch path, and if the shield is also far from many of the edge PoPs it serves, warm hits pay extra hop latency too. Shields are usually placed in or near the same region as the origin to minimize the miss-path cost.
Like a chain of corner stores each calling the same central warehouse individually every time they run low, versus routing all their restock calls through one regional distribution hub that calls the warehouse once and resupplies every store from its own stock.
saying these in an interview costs you the question
- Suggests the only fix for low hit ratio is 'just increase max-age' without checking cache-key fragmentation
- Doesn't know what an origin shield does structurally (thinks it's just 'a bigger cache')
- Assumes every edge PoP independently missing on the same object is unavoidable
- Confuses cache hit ratio with CDN uptime/availability