Prompt caching saves money only when the prefix stays unchanged
Across seven major provider ecosystems, prompt reuse follows the same basic rule: an unchanged beginning can be reused, while an edit near the front invalidates everything after it.

Key takeaways
Seven checked provider ecosystems reuse an unchanged prompt beginning rather than arbitrary later sections.
A larger prompt can cost less when it crosses the provider’s caching threshold, but changing early content invalidates subsequent blocks.
Separately cached passages can reduce answer quality when moved into a new context, even after position correction.
Research systems including CacheBlend, EPIC, APE, Block-Attention and KVLink explore ways to recover quality or enable broader reuse.
Prompt caching can make repeated long instructions far cheaper, but its savings depend on where changes occur. Across documentation checked for Anthropic, OpenAI, Google Gemini, AWS Bedrock, DeepSeek, Mistral and xAI, the common pattern is reuse of an unchanged beginning—not arbitrary sections of a prompt.
The price difference can be substantial. The source reports that cached input costs roughly one-tenth of normal input pricing on most Claude and OpenAI models. In one example, making an agent’s instructions 3.5 times longer lowered the bill by 41% because the prompt became large enough to qualify for caching. But moving content that changed on every step to the front made the same material 5.2 times more expensive.
Why an early edit has a large blast radius
Providers divide the prompt into blocks. Each block is associated with a hash derived from its contents and the preceding block’s hash. That creates a chain: altering one token in block two changes its identifier and causes every later block to miss the cache.
This explains why “stable content first” is more than a formatting preference. Put durable instructions and repeated context at the beginning, then place per-request material later. The exact minimum prompt size, retention period and cache-write pricing vary by provider, so teams still need to check the service they use.
Reuse is not automatically equivalent to recomputation
The cached object is the model’s key-value state, not simply saved prompt text. Reusing a passage in its original location produced the same output as recomputing it in the reported pre-check. Moving that passage to a new location is different: its internal state reflects the tokens that preceded it.
Position correction can align keys for models using RoPE, and the source found exact agreement at the first layer in its test. Later layers still diverged from a full in-context calculation. The values were unaffected by the position adjustment, because the rotation applies to keys.
Accuracy and serving implications
Experiments with Qwen2.5-3B-Instruct on two free Kaggle GPUs measured the risk of independently cached passages. On 200 HotpotQA and 200 2WikiMultihopQA questions, with roughly 5,500 context tokens, separately cached passages reduced F1 from 0.50 to 0.30 on HotpotQA and from 0.39 to 0.29 on 2WikiMultihopQA. Position correction recovered nothing in that test.
Several research systems target this gap. CacheBlend, available through LMCache, recomputes about 15% of the tokens whose internal state drifts most and reports a 2.2-to-3.3-times faster first-token arrival than full computation. EPIC recomputes the opening tokens of each passage, while APE changes the layout and attention scaling. Block-Attention and KVLink instead retrain models to combine separately cached passages.
For engineering teams, the immediate lesson is twofold: design API prompts around a stable prefix, and treat independently reused passages as an accuracy-sensitive optimization rather than a drop-in replacement for full-context inference.
Why it matters for your role
Pick the building you work in.

For AI and ML practitioners
Prompt layout is a direct cost lever: stable instructions should precede changing request data, while provider-specific thresholds and cache lifetimes must be verified. AI teams should also measure answer quality when reusing passages outside their original position.

For software engineers
The block-hash dependency means a small edit near the start can invalidate all downstream cache entries. Serving implementations that reuse separate passages need correctness tests, not only latency and cost measurements.

For planners and strategists
Caching estimates should separate documented API savings from model-serving research results. The reported timing came from a custom experiment on a T4 GPU, while accuracy tests used one model and two benchmarks.
Based on reporting by DEV Community (source article).
Written with AI assistance and reviewed under our editorial standards. Spotted an error? Tell the desk.








Comments