You put a CDN in front of your site. Cache hit rate is 12%. Origin load is barely reduced. Why?
Show the full answer Hide the answer
What the interviewer is testing
Whether you know the specific things that defeat edge caching, most of which are application behaviours rather than CDN configuration.
The likely causes
Cache-Control headers. The origin sends no-store, private, or nothing at all — many frameworks
default to no-cache for safety. Without explicit caching headers, the CDN cannot cache.
Set-Cookie on every response. Most CDNs will not cache a response carrying a cookie, and a session framework that sets one on every request — including for anonymous visitors — makes the entire site uncacheable. This is extremely common and is usually the answer.
Cache key includes varying elements. Query parameters from analytics and campaign tracking make
every URL unique. A Vary header on something high-cardinality such as User-Agent fragments the
cache into near-uselessness.
Everything is personalised, or is assumed to be. Frequently only a fragment of the page is user-specific and the rest could be cached.
Very short TTLs set defensively.
The fixes
Set explicit cache headers per content type: long TTLs with immutable naming for static assets,
short TTLs with stale-while-revalidate for dynamic content, private only for genuinely
personalised responses.
Stop setting cookies on cacheable responses, and configure the CDN to ignore cookies that do not affect the content.
Normalise the cache key — strip tracking parameters, sort remaining ones, and Vary only on
headers that genuinely change the response.
Separate personalised fragments so the shell is cacheable and personalisation is fetched client side or assembled at the edge.
What a strong answer adds
Stale-while-revalidate and stale-if-error as the highest-value settings beyond hit rate: they let the CDN serve slightly stale content while refreshing in the background, and continue serving during an origin outage — which turns the CDN into an availability mechanism, not just a performance one.
And the cost angle: CDN egress is usually much cheaper than origin egress, so hit rate is a direct cost lever as well.
Common weak answers
Increasing TTLs without addressing cookies. Changing CDN provider.