DEV Community

Cover image for Your Cache Hit Rate Is Lying to You
Cachely Admin
Cachely Admin

Posted on

Your Cache Hit Rate Is Lying to You

Your remote cache dashboard shows an 80% hit rate.

That sounds good.

It probably means fewer builds, faster CI, and less repeated work across the team.

But does it?

Technically, your cache hit rate is not lying. It is answering exactly one question:

How many cache lookups found a reusable result?

The problem is what we assume that answer means.

A high hit rate does not necessarily mean the cache is saving meaningful time. A low hit rate does not necessarily mean the cache is failing.

What matters is not only how many tasks were cached.

What matters is which tasks were cached, how expensive they were, and how much work the cache actually avoided.

The problem with counting every hit equally

Cache hit rate is usually calculated as:

cache hits / total cache lookups
Enter fullscreen mode Exit fullscreen mode

If a pipeline performs 100 cacheable tasks and restores 80 of them, the hit rate is 80%.

Simple.

But this calculation treats every task as equally valuable.

A formatting check that takes one second counts the same as an integration test suite that takes five minutes.

Both produce one cache hit.

They do not produce the same value.

80% can be worse than 20%

Consider a hypothetical pipeline with 100 tasks:

Task type Number of tasks Average duration
Formatting and linting 80 1 second
Builds and tests 20 5 minutes

In the first run, all 80 small tasks hit the cache, but every build and test misses.

The dashboard reports:

80 hits / 100 lookups = 80% hit rate
Enter fullscreen mode Exit fullscreen mode

The cache avoided around 80 seconds of repeated work.

Now reverse it.

All the small tasks miss, but the 20 expensive builds and tests hit.

The dashboard reports:

20 hits / 100 lookups = 20% hit rate
Enter fullscreen mode Exit fullscreen mode

The cache avoided around 100 minutes of repeated work.

The 20% hit rate delivered far more value than the 80% hit rate.

This is why a hit percentage cannot tell the full story.

Measure avoided work

The more useful question is not:

How many tasks hit the cache?

It is:

How much work did the cache prevent us from repeating?

That requires more context than a hit count.

A useful remote cache dashboard should help teams understand:

  • the duration associated with reused tasks
  • which task types produced the most savings
  • where expensive cache misses occurred
  • how reuse changes between projects and workloads
  • whether cache performance is improving over time

The goal is not to maximize cache activity.

The goal is to avoid repeating expensive work when reuse is safe and worthwhile.

A cache hit is not automatically valuable

Not every task benefits equally from remote caching.

Suppose a task normally completes in less than a second.

Restoring its cached result still involves some overhead:

  • a remote lookup
  • authentication
  • artifact retrieval
  • decompression
  • filesystem writes

For very small tasks, the value of caching may be negligible.

For expensive builds, test suites, or code-generation tasks, the difference can be significant.

This gives us three useful categories.

High-value hits

The reused result represents work that previously took a meaningful amount of time.

Low-value hits

The cache worked, but the original task was already inexpensive.

Potentially negative-value hits

The overhead of retrieving and restoring the result may be similar to, or greater than, running the task again.

A hit-rate dashboard treats all three as successes.

That is why the percentage needs context.

Time saved also needs a definition

Even “time saved” can mean different things.

Suppose a cached task previously took ten minutes.

Reusing it may avoid ten minutes of task-related work, but it does not necessarily shorten the entire pipeline by ten minutes.

The task may have been running in parallel.

It may not have been on the pipeline’s critical path.

There are several different measurements teams may care about:

Task-related time avoided

How much observed work did not need to happen again?

Pipeline wall-clock reduction

How much sooner did the developer or CI pipeline receive its final result?

Compute cost avoided

How much runner or infrastructure usage was potentially avoided?

These values are related, but they are not interchangeable.

A dashboard should be clear about which one it reports.

How Cachely estimates time saved

Calculating time saved requires a baseline.

When a task misses the cache, Cachely measures the elapsed time from the initial cache miss until the resulting artifact is stored.

That observed duration may include:

  • task execution
  • artifact preparation
  • uploading the result to the remote cache

When the same result is reused later, Cachely uses that previous observed duration to estimate how much work did not need to be repeated.

This is best understood as estimated time avoided, not guaranteed pipeline wall-clock reduction.

It does not attempt to model the pipeline’s critical path, and the observed duration may include more than pure task execution.

It still provides useful context.

Reusing the result of a task that previously took several minutes is generally more valuable than reusing one that completed in a few seconds.

Break the numbers down by task type

An organization-wide average can hide the most important details.

Imagine a workspace reporting a 70% overall hit rate:

Task type Hit rate
Formatting 98%
Linting 92%
Unit tests 65%
Builds 38%
Integration tests 12%

The headline looks healthy.

The breakdown tells a different story.

The cheapest tasks are reused consistently, while some of the most expensive tasks still run almost every time.

That leads to better questions:

  • Are builds being invalidated too broadly?
  • Are tests depending on unstable inputs?
  • Are environment variables unnecessarily changing cache keys?
  • Are generated files deterministic?
  • Are dependencies or lockfiles changing unexpectedly?
  • Are developers and CI using compatible toolchain versions?

Cache analytics become useful when they help improve the build system, not merely describe it.

Prioritize misses by cost, not frequency

A cache miss is not automatically a problem.

The source code may have changed.

A dependency may have been updated.

The toolchain version may be different.

Those are legitimate reasons to execute the task again.

Even avoidable misses are not equally important.

A one-second task that misses 1,000 times creates around 17 minutes of repeated work.

A ten-minute task that misses 20 times creates more than three hours of repeated work.

Sorting misses by frequency puts the one-second task first.

Sorting them by estimated impact points to the task that matters.

A useful investigation should start with:

Which cache misses caused the most repeated work?

Not:

Which cache key missed most often?

There is no universal “good” hit rate

Across the workspace data published in Cachely’s benchmarks, cache reuse varies significantly depending on workload and usage.

Smaller or lower-volume workspaces may see reuse closer to 25%.

Busy workspaces with more repeated activity can reach around 75% reuse.

That does not make 75% a universal target.

It also does not make 25% a failure.

A smaller workspace may have:

  • fewer concurrent branches
  • fewer developers
  • less repeated execution
  • a colder cache

A busy monorepo may reuse results across many developers, pull requests, and CI jobs.

The value depends on the workload behind the percentage.

A 25% hit rate on expensive tests may be worth more than a 75% hit rate on tiny checks.

The number needs context.

A better remote cache scorecard

Instead of relying on one headline metric, evaluate the cache across a small set of signals.

Reuse

  • overall cache hit rate
  • hit rate by task type
  • activity by framework, repository, or project

Time

  • observed uncached task durations
  • estimated time avoided
  • savings by task type

Cost

  • compute time potentially avoided
  • estimated runner cost savings

Miss impact

  • most expensive missed tasks
  • repeated high-cost misses
  • projects with consistently low reuse

Hit rate still belongs in the scorecard.

It just should not be the entire scorecard.

Do not optimize the dashboard

Metrics influence behavior.

When hit rate becomes the primary goal, teams naturally try to increase it.

They cache more tasks.

They store more artifacts.

They investigate frequent misses even when those misses cost almost nothing.

The dashboard improves, but the developer experience may not.

The real goal is simpler:

Avoid repeating meaningful work when reuse is safe and valuable.

That may produce a 90% hit rate.

It may produce a 40% hit rate.

The outcome matters more than the percentage.

Was the cache worth it?

Every remote cache system should eventually help answer one question:

Was the cache worth it?

To answer honestly, we need to know:

  • what was reused
  • how much observed work was associated with it
  • which task types benefited
  • where expensive misses still happen
  • how much time and compute may have been avoided

Cache hit rate is part of that answer.

It is not the answer.

Cachely is a managed remote build cache for Nx, Lerna, Turborepo, Gradle, and Bazel.

It works through native tool integrations, stores cache artifacts in Cloudflare R2, and reports cache hit rate, observed task durations, estimated time and cost savings, and task-level breakdowns.

There is no cache server to deploy or maintain, and a free plan is available.

Try Cachely for free →

Top comments (1)

Collapse
 
cachely-admin profile image
Cachely Admin

How do you measure the value of remote caching today? Hit rate, time avoided, pipeline duration, cost savings, or something else?