Inference 101, lesson 7
Caching: not reading the same thing twice
Most prompts start the same way every time, and a model need not read that start twice. This lesson shows what a cache keeps, the one changed word that breaks it, when caching costs more than it saves, and which answers your own app can keep.
Every example below changes to fit what you pick. The businesses are made up for teaching.
The picture, one step at a time
Each box is one stage. The picture lights up as you scroll.
Caching, from the repeated start to the stored answer
1The part that never changes
Instructions, tools, reference documents: the same words atop every request.
2Matched from the first word
A cache counts up to the first word that differs. The rest is read again.
3Notes kept for a while
The model's notes on that start are kept for minutes, sometimes an hour, then let go.
4Paid to store, cheap to read
Storing notes can cost a little extra; reading them back costs a fraction.
5Shared inside the server
Serving software can keep one copy of a common start and share it across many users.
6Whole answers kept
Your own app can store the reply to a question asked word for word, and skip the model.
A cache: the model's notes on a repeated start.
Step 1 of 7
Not reading the same pages twice
Lesson 3 showed that a repeated start can be charged less. Here is why. When the model reads your prompt it writes notes on every token. If the next prompt starts the same way, those notes can be kept and reused instead of written again. Picture a bookmark: you pick up the book and carry on from where you stopped, without reading the first fifty pages again. Where the picture breaks: this bookmark only works if not a single word before it has changed, and it falls out after a few minutes unused.
Step 2 of 7
Exact, from the first word
A cache matches from the very first token up to the first one that differs. Change one word near the top and everything after it is read again at full price. The usual culprits are small: today's date or time in the instructions, the customer's name in the first line, or a tool list that comes out in a different order each time.
Anthropic's guide says cache hits "require 100 percent identical prompt segments", and that a change to the tool list throws away everything cached after it (read 29 November 2026).
Which of these stops a long set of instructions from being cached?
Step 3 of 7
The notes fade
Notes take room in the chip's memory, so providers only keep them for a short while. Each time the start is used again the clock usually resets. A start used every few seconds stays cached all day. A start used once an hour may be gone every time. Some providers sell a longer life for a higher storage price.
As of November 2026: Anthropic keeps a cache for 5 minutes, reset free on each use, or 1 hour at extra cost. OpenAI caches automatically and says entries usually last 5 to 10 minutes of quiet, up to an hour, or up to 24 hours with extended retention. Google's explicit caches last 1 hour unless you set another time, and storage is billed for that time.
Step 4 of 7
Paying to store, saving to read
Storing the notes can cost a little more than normal input, and reading them back costs much less. Take made-up prices: a 20,000-token start costs 2p to read normally, 2.5p to store and 0.2p to read back. Ten requests inside the window cost 2.5p plus nine at 0.2p: 4.3p instead of 20p. But if your requests come ten minutes apart and the cache lasts five, every request pays to store again: 25p, dearer than not caching at all.
As of November 2026, Anthropic charges 1.25 times the normal input price to store for five minutes, twice the price for an hour, and a tenth of the price or less to read. OpenAI says cached input is discounted by up to 95%, and its newest models charge 1.25 times to store. Prices change: check the current list.
Step 5 of 7
Shared across users, inside the server
The same idea works inside serving software, across different people. If a thousand users' requests all start with the same instructions, the server can work out that start once, keep one copy of the notes, and share it. Skipping that reading also gets the first word out sooner, because the model has less to read before it can start writing (lesson 1).
The SGLang paper (Zheng and others, 2023) keeps these shared starts in a tree it calls RadixAttention, so any request can reuse the longest start it shares with earlier ones. It reported up to 6.4 times the throughput of other serving systems on its tests.
Step 6 of 7
Keeping whole answers
There is a bigger saving for questions asked word for word: keep the whole reply. Your own app stores the answer the first time and sends it again without calling the model. It costs nothing and answers at once. Where it goes wrong: the answer goes stale when the facts change, and a question that is only similar is not the same question.
Which reply is safe to store and send again?
Step 7 of 7
What this means for you
Lay out every prompt for answering customers in three layers: what never changes first, what changes now and then next, and the new question last. Keep the first layer word for word identical. Then look at your usage report: most providers show how many input tokens were read from the cache. If that number is near zero, something at the top is changing.
What can be cached here?
Here are four AI jobs in your business. Sort each one: cache the start of the prompt, keep the whole answer, or is there nothing worth caching?
1Every chat begins with the same 6,000-token returns and delivery policy, and you have hundreds of chats a day.
2"What time do you close on Saturday?" arrives, word for word, about 200 times a week.
3Customers ask "is the green scarf in stock?" dozens of times a day.
4Once a month you send one long, unusual complaint with a two-line instruction for a careful reply.
0 of 4 right so far, 4 to go.
What can be cached, on one card
This is what you keep: what a cache saves, what breaks it, and how to lay out a prompt so it works.
What can be cached, on one card
- A cache keeps the model's notes on the start of a prompt, so the next prompt that starts the same way is read faster and billed less.
- It matches from the first word to the first change. A date, a name or a reshuffled tool list near the top, and everything after it is read again.
- Order matters: fixed instructions and tools first, slow-changing documents next, the new question last.
- It fades after minutes, or an hour if you pay (November 2026). Storing can cost extra, so a start used once a fortnight is cheaper uncached.
- Your own app can keep whole answers to questions asked word for word, as long as the answer cannot go stale.
Fixed first, new last, and check your usage report for cached tokens. If there are almost none, something at the top keeps changing.
Next: Lesson 8: Quantisation: smaller numbers, smaller bills. How rounding a model's numbers makes it cheaper to run, and what it can cost in quality.