Prompt caching: what it saves and when it doesn't
Prompt caching saves money only when the same prompt prefix repeats. Learn what it saves, when it does nothing, and how to measure your own bill.
Updated
Prompt caching saves money when many requests begin with the same text. The provider keeps the processed form of that shared prefix, so a later request that repeats it pays a lower rate for those tokens. Caching does not change the answer, and it does nothing for text that changes on every call.
Where the savings come from
Most production prompts have two parts. The first is fixed: system instructions, an output schema, worked examples, a policy document. The second changes on each call: the document or message the call is about. The fixed part is the cacheable prefix. The changing part is billed at the normal input rate every time.
The saving depends on two things: how long the fixed prefix is, and how often it is reused before the cache entry expires. A short prefix saves little, however often it repeats. A long one sent many times in a short window saves the most.
Here is a worked example at Claude list prices. Haiku input costs $0.10 per million tokens. Suppose a 9,000-token instruction block sits in front of a 1,000-token document. Uncached, the block costs $0.0009 per call and the document $0.0001. Almost all of the input cost is the block, so it is the part worth caching.
The same block on Opus, at $4 per million input tokens, costs $0.036 per call uncached. If that call also writes a 500-token answer at $20 per million output tokens, the answer costs $0.01. Caching can only shrink the $0.036 line, so on output-heavy calls it removes little of the bill.
When prompt caching does nothing
Several common setups miss the cache entirely. Check for each one before you tune anything.
- The prefix changes. A timestamp, a user name or a request ID near the top makes every request unique from the first token. Move those values below the fixed block.
- Traffic is sparse. Entries expire after a period of inactivity. If calls arrive further apart than that, each one writes a new entry and few reads follow. Unrelated jobs spread across a day are a common case.
- The prompt is short. Providers cache only prefixes above a minimum length. Check your provider’s current documentation for the figure, because it changes.
- The variable part is the bulk. Document extraction often sends a long, different document with a short shared instruction. Only the instruction repeats, and it may be too small to matter.
- The cost is mostly output. Caching applies to input tokens only. If long generated answers dominate the bill, caching barely moves it.
Two mistakes come up often. A “today’s date” line added to a system prompt breaks the match on every call, and it looks harmless in review. A tool list built from a set or from unordered query results changes order between runs, so identical-looking requests are not identical bytes.
How to structure a prompt so it caches
Order is the main lever. Put everything that stays the same first: system instructions, tool definitions, schemas and examples. Put the per-call content last. Keep the fixed text identical from call to call, including whitespace, because one changed character ends the match.
Tool definitions and schemas need the same care. If your application adds a field to a tool only for some users, or lists tools in a different order per request, every call that follows misses. Keep per-user or per-tenant data out of the shared block when you want one entry to serve many users. Put that data in the final message instead.
Before you ship a change to a prompt, run this checklist:
- Keep the fixed block in one constant or file and import it everywhere.
- Move timestamps, IDs and user names below the fixed block.
- Sort tool lists and any set-derived content into a fixed order.
- Log cached and uncached token counts on every call.
- Diff two requests from the same hour to find the byte that differs.
Test the structure with logs, not intuition. A small reordering can move a prefix from unique to shared, and a small edit can move it back.
Caching is not a model choice
Caching lowers the input cost of a long prompt on the model you already use. It does not change which model you pay for, so compare the options in the LLM cost calculator first.
Fixed instructions are sometimes better replaced than cached. A model trained on the task can carry its conventions in its weights, so the prompt shrinks to the document and a short request. That removes the cacheable prefix altogether, which can beat any hit rate. Our full results compare that approach with prompted models on a contract task.
The Batch API is half price for Claude when the work can wait. If a job runs overnight, check whether batching fits before you tune caching. See batch APIs against real-time calls.
Measure the saving on your own traffic
Read the usage fields your API returns. Most providers report cached input tokens separately from uncached ones. Log both on every call, then compute the bill from those counts rather than from an estimate. The ratio of cached to uncached tokens gives your hit rate. A low hit rate points to a changing prefix or sparse traffic, and both are fixable.
Compare cost per completed task, not cost per call. Retries, fallbacks and long outputs all show up in the usage counts, and they can hide a good hit rate. Look at daily totals for a week before you decide anything. Bursty traffic usually gets more from caching than steady, sparse traffic does, so one quiet day can mislead you.
Own Weights offers a free AI cost audit. It reads your code on your machine, uploads nothing, and saves a PDF of your AI calls, their estimated cost and whether prompt caching is missing. Use the button below if you want help reading the results.
Questions
Will prompt caching change my model's output?
Not in principle. Caching changes what the repeated input tokens cost to process, while the prompt the model reads stays the same. Still, confirm in your own tests that cached and uncached requests return the same results for your task.
How long does a prompt cache entry last?
It depends on the provider, and the window is short enough that calls spread across a day often miss it. Read your provider's current documentation rather than a number from a forum post. Bursty traffic usually gets more from caching than steady, sparse traffic does.
Is prompt caching enough to cut an LLM bill?
Sometimes. It helps most when a long, fixed prefix repeats often and input tokens make up most of the cost. If output drives the bill or every call is different, the model choice and the task design matter more.