The cache that never hit
Step 1 · The pattern
A long prompt, mostly the same every time
Every request carries the same tool definitions and policy documents (thousands of tokens), then the user's question. The provider caches the work on that identical prefix: about 90% of requests hit, read the prefix at a fraction of the price, and answer sooner. (All numbers are illustrative.)
- a request
- cache hit
- miss: full price
In short
The cache that never hit: how it works and how it breaks
A support assistant sends the same long system prompt, tool definitions and policies with every request, then the user's question. Prompt caching reuses the work on a prefix that exactly matches a recent request: cached input costs a fraction of the normal price (around a tenth on several current models) and answers start sooner. The match is exact and in order; Anthropic's documentation requires identical prompt segments, and OpenAI's says the entire rendered prefix must match. Put anything that changes on every request near the top, such as the current time, a request ID or reordered tools, and every request misses: input cost and latency rise several times over, with no error. Prompts below the minimum cacheable length are silently not cached either. Put stable content first and changing content last, keep tools stable, and graph the share of input read from cache.
What this simulation simplifies
- Hits are a fixed 90% chance; real hit rates depend on traffic, expiry and routing.
- Cost is shown as hits and misses, not in currency.
How this comes up in interviews
"How would you cut the cost of an assistant that sends a 20,000-token system prompt with every request?"
Then they ask
- How does prompt caching match?
- What breaks it?
- How would you notice?
A strong answer covers
- Prompt caching reuses an exact prefix at a fraction of the input price.
- Order: stable tools and documents first, changing content last.
- Avoid timestamps, IDs and reordered tools near the top.
- Monitor cache-read share and cost per request per route.
- Consider batch APIs for work that can wait.
Points to cover, not a script. Say them in your own words and tie them to a system you have worked on.
On one page: the track cheat sheet.
Sources: Anthropic API docs: Prompt caching ↗ · OpenAI API docs: Prompt caching ↗ · Report a problem
Diagrams are our own simulations: the timings, rates and counts in them are illustrative, not measurements. Captions are original wording.