Edge Caching Economics: Hit Ratio Is the Whole Product

Edge platforms are usually sold on latency, and they are usually bought on cost. Both come from the same variable: how many requests are served at the edge instead of travelling to an origin. A cache with a ninety-five percent hit ratio is a different product from one with seventy percent, not because of the hardware but because twenty-five percent of traffic is doing a full round trip, paying origin compute, and arriving slower than the user expects.

The short version: measure hit ratio by route and by device, not globally. A global figure hides the routes that matter, and it hides the misses that only happen to logged-in users, which is usually where the money is.

What counts as a hit, and what quietly does not

A hit means the edge returned a response without contacting the origin. A revalidation, where the edge asks the origin whether its copy is still fresh and gets a 304, is a hit for the user and a miss for the origin, and it is priced differently on almost every platform. If your monitoring counts only full hits, the revalidation traffic can quietly dominate origin cost while the dashboard looks healthy.

Normalise the definition before comparing anything. Log per request: edge status, whether the origin was contacted, cache key used, and response age. That single log line makes every later discussion about tuning concrete, and it is the cheapest thing in this article.

Cache key design decides the ceiling

The hit ratio is mostly determined before any runtime code runs, by what the cache key includes. Include the user’s session cookie and the ratio collapses: every visitor becomes a unique key. Include nothing but the path and you serve stale or wrong content to people who should see something personalised. The useful middle is a key built from path plus a small number of genuinely varying dimensions: device class, locale, and an explicit variation parameter for A/B tests.

A practical technique is to split the page: cache the shell and the public fragments at the edge, and fetch the personalised fragments from a small authenticated API at request time. The shell hit ratio stays high, the personalised call is small and cheap, and correctness is preserved. This is often the difference between sixty and ninety-five percent, and it requires a front-end change rather than a bigger cache.

Compute at the edge is priced per invocation

Running logic at the edge adds requests and billed compute, so it must remove more than it costs. The cases that justify it are header rewriting, geo-based redirects, small personalisation lookups, and auth token validation. The cases that do not are anything requiring a large dataset, a wide dependency tree, or several sequential network calls, because edge invocations are short-lived and each round trip is a billed unit.

Compare the two designs on cost per thousand requests rather than on elegance: origin compute plus bandwidth plus cache fill, versus edge invocations plus cache miss traffic. The edge usually wins on latency and frequently loses on cost for low-volume routes, which is exactly the kind of thing a spreadsheet settles in twenty minutes.

Invalidation is where the bill hides

Purging is usually priced per call or per object and is easy to trigger accidentally. A deployment that purges the whole cache on every release turns a high hit ratio into a recurring cold cache, and the origin cost spike after each deploy is often misattributed to traffic. Purge by tag or by path, and purge only what changed.

Set TTLs with intent rather than by copying a default. Product pages can tolerate minutes; price and inventory fragments need seconds; legal text can live for hours. A single global TTL of five minutes is a decision that makes every page as expensive as the most volatile one.

A worked example: from sixty to ninety-four percent

A content site serves ten million monthly page views. The full response is cached with a key that includes the session cookie, which means every visitor gets a unique entry and the hit ratio sits at sixty-one percent, almost all of it repeat visitors within a session. Origin traffic is 3.9 million requests a month and the bill is dominated by that.

The first change moves authentication out of the render path: the HTML shell is cached keyed on path, device class, and locale, and a small authenticated fragment is fetched client-side from an API. Hit ratio rises to eighty-nine percent. The second change sets per-fragment TTLs, so that product availability refreshes every thirty seconds while article bodies live for six hours, and stops purging the entire cache on every publish. Hit ratio reaches ninety-four percent and origin traffic falls to six hundred thousand requests.

The authenticated fragment becomes the new cost centre, at roughly one call per page view, but it is a small JSON payload served by a cached API route. Total spend falls even though the architecture has one more component, which is the shape these projects almost always take when the measurement is done first.

What to check before you commit

  • Define hit, revalidation, and miss in one log line, and use those definitions everywhere.
  • Report hit ratio by route and by audience segment, not as one global number.
  • Keep session-dependent data out of the cache key; split personalised fragments instead.
  • Compare edge compute against origin cost per thousand requests before adopting it.
  • Purge by tag and only on real content changes.
  • Set TTLs per fragment type, not one default for the site.

Edge caching rewards the team that instruments first and tunes second. The tuning itself is mostly a matter of cache keys and TTLs, and both are cheap to change once you can see which requests are actually missing.

One last note on measurement hygiene: report hit ratio as a rate over a rolling hour rather than a daily average, because deployment purges and traffic spikes both distort the daily figure in opposite directions. A daily average can hide a recurring pattern of cold caches every morning at deploy time, which is precisely the pattern that produces the highest origin spend. Hourly reporting makes that visible, and the fix, usually purging by tag instead of by path, is then obvious to everyone who looks at the graph.

Leave a Comment