Cache Hit Ratio Calculator: Hit Rate, Latency and Origin Savings
By FindMySum · Last reviewed
A cache hit ratio calculator turns a cache's hits and misses into the numbers that matter to users and budgets: how fast the average request is, how much traffic still reaches the origin server, and what that traffic costs. Enter a hit ratio, or the hit and miss counts from your cache's statistics, along with the response times for hits and misses.
The hit ratio
A cache answers a request from its own copy (a hit) or passes it to the slower origin (a miss). The hit ratio is the share of hits:
hit ratio = hits ÷ (hits + misses)
Redis reports the counts as keyspace_hits and keyspace_misses, Memcached as get_hits and get_misses, and CDNs show the ratio in their dashboards. 950,000 hits and 50,000 misses give 95%.
Average response time
Hits and misses take very different times. The average is weighted by how often each happens:
average time = hit ratio × hit time + miss ratio × miss time
The calculator opens at 90% with 20 ms hits and 250 ms misses: 0.9 × 20 + 0.1 × 250 = 18 + 25 = 43 ms, almost six times faster than sending everything to the origin. Notice that the 10% of misses contribute more to the average than the 90% of hits. That pattern holds whenever misses are much slower than hits, and it is why tuning efforts focus on the misses.
Computer architects use the same idea for CPU caches, where it is called average memory access time: hit time plus miss rate times miss penalty.
Load on the origin
The origin only serves the misses:
origin requests = total requests × miss ratio
With 50 million requests a month at 90%, 5 million reach the origin. This is where the hit ratio's leverage is clearest. At 99%, origin requests fall to 500,000; at 99.9%, to 50,000. Each extra nine divides the origin's load by ten, even though the hit ratio itself barely seems to move. When a cache is sized or configured, the miss ratio is the number that decides how big the origin must be.
Transfer costs
Data leaving a cloud origin is usually billed per gigabyte. The calculator multiplies the origin requests by the average response size and the price per GB. With 100 KB responses, the 5 million misses send 500 GB, which at the example price of $0.09 per GB (Amazon S3 data transfer out, November 2026) costs $45.00, against $450.00 if every request went to the origin. Enter your provider's price and your average response size under the advanced options.
Two conventions matter here. Data sizes can be decimal (1 KB = 1,000 bytes, 1 GB = 10^9 bytes) or binary (1 KiB = 1,024 bytes, 1 GiB = 2^30 bytes), and providers differ in which they bill, so the calculator lets you choose. And a CDN charges for its own delivery to users; that cost isn't included, because it applies to hits and misses alike.
Raising the hit ratio
Common ways to turn misses into hits:
- Give the cache enough memory for the working set, the data requested often enough to be worth keeping. An eviction count that keeps rising is a sign it is too small.
- Cache for longer where the data allows, using validation (ETag, Last-Modified) to refresh cheaply instead of refetching.
- Normalise cache keys. Strip tracking parameters, sort query strings and avoid varying on headers or cookies that don't change the response.
- Serve stale content while revalidating so an expiring entry doesn't send a burst of misses to the origin.
- Cache negative results (a "not found" answer) for a short time, so repeated lookups for missing keys don't all reach the database.
Measure before and after: the hit ratio, the average and tail latency, and the origin's request rate.
More questions
What lowers a cache hit ratio?
Too little memory for the working set, so useful entries are evicted; time-to-live values shorter than the data really needs; cache keys that include needless detail such as tracking parameters or cookies, which split one object into many; and traffic that is genuinely unique, such as personalised pages or search queries.
What is a cold cache?
A cache that has just started or been cleared and holds nothing yet, so almost every request misses. Its hit ratio climbs as popular items are fetched. After a deployment that flushes a cache, the origin briefly sees close to full traffic; warming the cache first or rolling the change out gradually avoids the spike.
Does a higher hit ratio always mean a better cache?
Not always. You can raise the hit ratio by caching longer, at the cost of serving stale data, or by caching only cheap objects while expensive ones still miss. The figure to optimise is usually the total origin work or the user-facing latency, which this calculator derives from the hit ratio.
What is average memory access time?
The CPU-cache version of the same formula: average memory access time = hit time + miss rate × miss penalty. It is equal to the weighted average used here when the miss time includes the time spent checking the cache first. Computer architecture textbooks use it to compare cache sizes and levels.
How does a cache stampede happen?
When a popular entry expires, many requests miss at the same moment and all go to the origin to rebuild it. Request coalescing (letting one request refill the entry while others wait), serving stale content while revalidating, and adding randomness to expiry times all prevent it.
Sources
This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.