We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
4 system design questions lean on this idea. Each walks through the full answer.
System Design Masterclass · Caching Strategies
Free preview: the first 2 parts of this 11-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Caching Strategies
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
Whether a response can be cached at the edge is usually discussed as a single question, answered by Cache-Control. The more interesting question is how many copies the edge has to keep, because that is what decides the hit rate.

Vary tells a cache that the response depends on a request header, so it keeps one entry per distinct value of that header. Adding a header to Vary does not stop a response being cacheable. It multiplies the key space.
The hit rate of an edge cache is a property of how many distinct keys your traffic produces, and one header in one response decides that number.

The origin is a real server on a socket and every miss is a real request through it. Nothing about the response body or its Cache-Control changes between the four runs.

The same 200 URLs became 200, 501, 7,628 or 18,404 distinct cache entries, and the hit rate fell from 99.0 percent to 6.5, purely because of which request headers the response said it varies on.

Nothing about the pages changed. The multiplier is set by how many distinct values your traffic has for the headers you named, which is three for encodings and one per session for cookies.

The origin load is the number to look at. It went from 200 requests to 18,706, which is ninety-three times, because of one header on one response.
Work out the cardinality of every header in your Vary before shipping it. It is a count of distinct values in a day of access logs, and it is the factor by which your edge cache is about to be multiplied.
It is easy and good
“It is really nice and good Please join the course”