AI Coding Cache Hit Rates: Is 99% Normal?
A 96%–99% cache hit rate can be reasonable in AI-assisted coding, where stable instructions, project context, and conversation history often make up most of the input. This article explains what prompt caching reuses, how to interpret request-level and token-level metrics, how to validate reported rates, and why task cost, latency, and code quality matter more than the cache percentage alone.
1. The Short Answer: It Can Be Normal, but Check What Is Being Cached
When an AI coding tool reports a cache hit rate of 96%–99%, a natural question is: if every turn introduces a new question, how can nearly all the input hit the cache?
There is no contradiction. The developer’s latest question is often only a small part of the full model request. That request may also include system instructions, tool definitions, project guidelines, conversation history, source code, and results from previous execution steps. When these elements remain unchanged between consecutive requests and meet the service’s caching requirements, much of the input may be reusable.
A high hit rate is therefore technically plausible in long-context, multi-turn coding workflows. Before interpreting it, however, answer three questions:
- Is the metric calculated by request count or by input token count?
- Does the cache reuse input computation or return complete responses?
- Which requests are included, and are there filtering, aggregation, or duplicate-counting issues?
These definitions determine whether 96%–99% indicates efficient reuse or simply reflects a particular workload.
2. What Caching Reuses—and What It Does Not
Input Prefix Caching
A model must perform computation on its input sequence. In inference services that support prefix caching, some intermediate computational state from a previously processed input prefix may be stored and reused when a later request meets the relevant conditions.
Consider two simplified requests:
First request:
Fixed instructions + tool descriptions + project context + question 1
Second request:
Fixed instructions + tool descriptions + project context + question 1 + answer 1 + question 2
If the second request preserves a reusable prefix from the first, the service may avoid repeating some computation for that portion of the input. Whether it actually hits the cache depends on the implementation, cache lifetime, isolation boundaries, and request consistency.
A cache hit usually does not mean that the service simply returns the previous complete answer. New input still needs to be processed, and a new response still needs to be generated. A high cached-input percentage does not imply that the model ignored the current question.
Prefix Consistency Matters More Than Semantic Similarity
Prefix caching typically depends on consistency in the input sequence and relevant execution conditions, not merely on similar meaning.
For example, “Check the function’s boundary conditions” and “See whether the function has any boundary-condition issues” are semantically similar. That alone does not establish that they can reuse the same prefix computation.
Changing the order of tool definitions, inserting dynamic fields into a fixed template, or rearranging project context can also change the input sequence. The exact effect depends on the caching mechanism, but the general principle is straightforward: the earlier unstable content appears, the harder it becomes to reuse later stable content as part of an identical prefix.
Different Cache Layers Serve Different Purposes
An AI coding workflow may also use file-read caches, retrieval-result caches, tool-result caches, and complete-response caches. These are distinct mechanisms and should not be treated as interchangeable.
If a model API reports “cached input tokens,” the relevant question is input computation reuse. If a dashboard displays an overall cache hit rate, first check how that metric is defined.
3. Why Coding Workflows Can Produce Very High Hit Rates
Stable Context Can Be Much Larger Than the New Question
A short request such as “Fix this error” may be accompanied by substantial context:
- Behavioral constraints and operating rules for the coding assistant
- Available tools and their parameter descriptions
- Project structure and coding conventions
- Relevant source code already read
- Previous changes and validation results
- The user’s latest requirement
A simple example illustrates the calculation.
Suppose a request contains 50,000 input tokens, of which 49,000 are reusable and 1,000 are new. Its input-token cache hit rate is:
Cache hit rate = 49,000 ÷ 50,000 = 98%
The current question does not need to be identical to the previous one. The percentage only shows that new content is a small fraction of the complete input, while reusable content accounts for most of it.
These numbers are illustrative, not performance measurements for any particular service.
Multi-Turn Tasks Naturally Preserve Context
Code fixes often follow a cycle:
Locate the issue → modify the code → run checks → analyze the results → make further changes
Throughout this process, the task objective, project background, and much of the conversation history remain continuous. If the tool builds requests around a stable prefix and appends new content, a high input reuse ratio becomes more likely.
Conversely, rearranging historical messages, generating differently formatted project summaries, or inserting dynamic information at the beginning of every request can reduce cache reuse even when the underlying task changes very little.
Longer Conversations Can Increase Both Reuse and Redundancy
As conversation history grows, each new question may account for a smaller share of the total input. That can make high hit rates easier to achieve.
It does not mean longer conversations are always better. History can accumulate incorrect assumptions, outdated source code, repeated logs, and information unrelated to the current task. Even when that content is cached, it still occupies context space and may interfere with the model’s understanding.
A high hit rate can therefore coexist with poor context management. Effective reuse and unnecessary context must be evaluated separately.
4. Define the Metric Before Calling It Abnormal
Request Hit Rate and Token Hit Rate Are Different
A request-level hit rate can be defined as:
Requests with a cache hit ÷ total requests
An input-token hit rate can be defined as:
Cached input tokens ÷ total input tokens
These metrics answer different questions. A request that reuses only a short block of fixed instructions may count as a cache-hit request even though its token-level reuse is low.
When a dashboard shows 99%, first identify the numerator and denominator.
Do Not Simply Average Per-Request Percentages
If request sizes vary substantially, the arithmetic average of individual hit rates can be misleading.
For example, a short request with a low hit rate and a long request with a high hit rate should not contribute equally to a metric intended to describe overall input reuse.
A more appropriate aggregate is:
Overall input-token hit rate = total cached input tokens across all requests ÷ total input tokens across all requests
This token-weighted calculation better represents input volume and cache utilization.
Verify Whether Cached Tokens Are Included in Total Input Tokens
Usage-field definitions can differ between services and proxy layers. In some reporting systems, cached tokens are a subset of total input tokens. Other displays list categories separately.
Without confirming the relationship between fields, it is easy to double-count tokens or choose the wrong denominator. Interpret usage data using the relevant API documentation and raw records rather than guessing from field names.
5. A High Hit Rate Does Not Guarantee Low Cost or Latency
Cost Depends on Billing Rules
Whether cached input receives a different price, whether cache writes incur fees, and whether other billing conditions apply depends on the service.
A general cost framework is:
Total cost = uncached input cost + cached input cost + output cost + other applicable charges
A 98% input cache hit rate therefore does not mean the total bill falls by 98%. Large outputs or repeated, ineffective steps in the coding workflow can still make a task expensive.
Latency Includes More Than Input Processing
Caching may reduce repeated input processing, but a coding task also involves request queues, network transfer, output generation, file operations, checks, and failed attempts that require retries.
A fuller performance assessment should track:
- Time to first output
- Time to complete an individual request
- End-to-end task completion time
- Number of model calls and tool calls
- Number of retries
- Whether the final changes pass validation
Cache metrics describe only part of the workflow. They cannot replace end-to-end measurement.
6. How to Validate a Reported 96%–99% Hit Rate
Start with Raw Usage Records
For each request, record:
- Total input tokens
- Cached input tokens
- Output tokens
- Request duration
- Session identifier and request order
- Whether retries or context rebuilding occurred
After confirming that cached input tokens are a subset of total input tokens, check that the cached count does not exceed the total and that the displayed percentage matches the raw data.
If the numbers conflict, investigate aggregation, field mapping, and retry counting before attributing the problem to the model.
Run Controlled Experiments
Use several request groups to observe how cache behavior changes:
- Keep the prefix fixed and append a small question at the end. This tests reuse of a stable prefix.
- Change fixed text at the beginning of the input. This tests the effect of an early prefix change.
- Reorder project context or tool descriptions. This checks whether request organization affects cache hits.
- Change the interval between requests. This helps reveal the effect of cache retention conditions.
Keep other conditions as consistent as possible and repeat the measurements. Results describe the tested configuration and environment; they should not be generalized to every service.
Separate Request Construction from Backend Caching
If the same AI coding tool produces high hit rates with multiple services, that does not prove those services share a cache.
A more reasonable explanation is that the tool consistently constructs large, stable inputs, while each service independently reuses its own eligible cached state.
Claims about cache sharing across sessions, accounts, or services require explicit evidence. Similar percentages are not enough.
7. Optimize Cost per Validated Task, Not the Hit Rate Alone
Organize Stable Content Consistently
Use a consistent order and format for fixed instructions, tool descriptions, and stable project guidelines. Avoid placing changing timestamps, status descriptions, or random identifiers inside an otherwise fixed prefix merely for presentation convenience.
Consistency is useful only when the content remains accurate and necessary. Do not retain incorrect information just to preserve cache hits.
Control Context Size
Keep file excerpts and execution results relevant to the current task. For long logs, retain the key errors, necessary surrounding context, and relevant locations. Merge repeated information, and summarize conclusions that remain valid after a task phase is complete.
Compressing or rebuilding context may temporarily lower the hit rate. It can still improve the overall workflow if it reduces irrelevant input, limits distraction, and shortens the task.
Check That Information Is Current
Once a file changes, older source snippets may no longer be accurate. A cache hit does not guarantee freshness and cannot replace checking file versions or validating the actual result.
The coding tool must ensure that critical context matches the current workspace, then verify changes through tests, builds, or other appropriate checks.
8. Conclusion: A High Percentage Can Be Reasonable, but It Is Not the Whole Picture
Cache hit rates of 96%–99% are possible in AI coding workflows with long context, stable prefixes, and multi-turn interactions that append new content. Such rates typically mean that most input qualifies for reuse—not that the new question was left unprocessed or that the response came entirely from an old answer.
A meaningful assessment also considers metric definitions, context size, data consistency, actual cost, task duration, and code quality.
The goal is not an impressive cache percentage. It is to complete validated code changes with accurate information, appropriately sized context, less repeated computation, and fewer ineffective calls.
