Guide
How AI caching works: subscription AI vs your own GPU
A model re-reads the whole conversation on every turn. Caching lets it keep its notes on the part it has already read, so only the new text costs time. Providers run that cache for you, with timers and their own prices. On your own GPU the cache sits in your server's memory and lasts while it runs.
Last reviewed November 12, 2026 · By OpenLLM Buddy · OpenLLM Buddy is not affiliated with OpenAI, Anthropic, Google, xAI or DeepSeek. Product names describe their published documentation.
1. Your first message
0% from cache
InstructionsYour documentQuestionNothing is cached yet, so the model reads all of it. This is the slowest turn.
2. A follow-up question
91% from cache
InstructionsYour documentFirst Q&ANew questionEverything up to the new question is unchanged, so it comes from the cache. Only the new question is read.
3. Something near the top changes
0% from cache
Edited instructionsYour documentChat so farQuestionA change at the start, even a date stamp, means nothing after it matches. The model reads everything again.
What caching is
A model has no memory between turns. Each time you send a message it is given the whole conversation again: instructions, files, every earlier message. Reading all of that is the slow, expensive part.
While it reads, the model builds internal notes on every token, called the key-value cache. Prompt caching keeps those notes after the turn ends. If the next request starts with exactly the same text, the model picks up its notes and only reads what is new.
The answer does not change. Anthropic and OpenAI both say a cached request returns the same response as an uncached one. What changes is the wait before the first word and, where you pay per token, the price.
- Anthropic measured a 100,000-token prompt starting to answer in 2.4 seconds with a cache, against 11.5 seconds without.
Sources: Hugging Face, Anthropic, OpenAI, Anthropic
What breaks a cache
The match runs from the very start of the request and has to be exact. One changed character near the top, and everything after it must be read again. That makes caches easy to break without noticing.
- Editing the instructions or an earlier message.
- A date or time stamp near the top that changes on every request.
- Adding, removing or reordering tools.
- Switching model, or changing the effort or thinking setting, partway through.
- Waiting too long: provider caches expire after minutes or hours of no use.
How ChatGPT, Claude, Gemini, Grok and DeepSeek run it
Every large provider caches, and for long prompts it is a real saving. Each sets its own rules for how you turn it on, what a cached token costs and how long the cache lasts. These are the rules for developers using each company's API.
| Provider | How it turns on | Cached input price | How long it lasts |
|---|---|---|---|
| OpenAI | Automatic, from 1,024 tokens | Discounted by up to 95% | 30 minutes by default on recent models; up to 12 or 24 hours on request |
| Anthropic (Claude) | You mark what to cache, or set it once for the whole request | Reads at about a tenth of the normal price or less; writing the cache costs 1.25 to 2 times normal | 5 minutes by default; 1 hour at a higher write price |
| Google (Gemini) | Automatic on recent models, from 2,048 or 4,096 tokens | One recent model lists $0.10 cached against $2.00 per million tokens | Not stated for automatic caching; stored caches are billed by the hour on some models |
| xAI (Grok) | Cached input has its own price | $0.30 to $0.50 against $2.00 per million tokens | Not published |
| DeepSeek | On by default | About one thirtieth of the normal price on its top model | Cleared within a few hours to a few days |
- Read from each provider's documentation in November 2026. Prices and timers change often; follow the sources for current figures.
- A cache hit is not promised. OpenAI describes its routing key as an aid, and DeepSeek calls its cache best-effort.
Sources: OpenAI, Anthropic, Google, Google, xAI, DeepSeek, DeepSeek
What you can see and control in the apps
In a chat app you are not billed per token, so caching mostly shows up as speed and as how fast you use your plan's allowance. We found no official page from OpenAI or Google that says whether their chat apps show cache use or let you control it.
Anthropic documents more. Claude Code caches automatically, shows the hit rate on its usage screen, and gives subscribers a one-hour cache on the main conversation. Through the API, Anthropic says cache reads do not count toward the per-minute input limit.
Because the provider runs the cache, a change on its side can affect you. In April 2026 Anthropic reported that a change it had shipped on March 26 caused cache misses on every turn for some Claude Code sessions. It fixed the fault on April 10 and reset users' usage limits.
Who shares the cache
A cache holds your prompt's contents in the provider's memory, so who else can reach it matters. Anthropic says its caches are never shared between organizations and are held in memory only for their lifetime. OpenAI says the same about sharing, and that caching works with its zero-data-retention option.
This was not always true across the industry. A 2025 study audited 17 API providers, detected caching at 8 of them, and found caches shared between all users at 7. Sharing matters because response timing can then reveal whether someone else sent the same prompt. At least five providers changed their systems after the researchers told them.
Caching when you run the model yourself
The same mechanism runs on your own server, minus the price list. The notes are simply held in your machine's memory.
llama.cpp, the server our Qwen template uses, caches by default: it compares each request with the last one in the same slot and only processes the part that differs. A slot is one conversation's worth of cache. It can also keep recent prompts in ordinary memory, 8 GB by default, and save a slot to disk to restore later.
vLLM reuses the notes for any shared opening across requests, which helps when many requests start with the same instructions. Ollama keeps a model loaded for five minutes after its last use by default, then unloads it, cache included, unless you change that setting.
- No timer set by a provider: the cache lasts until the server needs the room or restarts.
- No price per cached token: you pay for the machine, not for reads and writes.
- It is finite. The cache uses memory that grows with the length of the conversation.
- One slot serves one conversation well. Two conversations taking turns in one slot can push each other out.
Sources: GitHub, vLLM, Ollama, Hugging Face
Other things people call a cache
Three different things share the name. Only the first is what this page is about.
| Name | What it stores | Does it change the answer? |
|---|---|---|
| Prompt cache (key-value cache) | The model's notes on text it has already read | No. It only saves reading time |
| Response cache | A finished answer, returned again for the same or a similar question | Yes. You get a stored answer, not a new one |
| Model file cache | The downloaded model on disk, so it is not fetched again | No. It only saves download time |
Sources: Hugging Face, Hugging Face
How to get more cache hits, anywhere
The same habits help on a subscription, an API or your own GPU, because the rule is the same: keep the start of the request identical.
- Put what never changes first: instructions, then documents. Put the question last.
- Add to a conversation; do not edit earlier messages.
- Keep dates, times and request numbers out of the opening text.
- Choose the model and the thinking setting before you start, and leave them alone.
- Continue the same conversation, and do not paste the document into a new one.
- On a provider, come back before the timer runs out if you have a long document loaded.
What you get on Self Deploy
On Self Deploy the cache lives in the memory of your own GPU pod, serves only your instance, and has no per-token price and no timer of ours: it lasts while the pod runs. Our Qwen template keeps one conversation slot, and a restart clears the cache.
So a long document you loaded an hour ago is still cached when you ask the next question, as long as the same conversation is using the slot. It suits one person or one agent working through a long task. For several people at once, a provider's shared service or a larger setup with more slots fits better.
| Subscription AI and APIs | Self Deploy GPU | |
|---|---|---|
| Where the cache lives | In the provider's servers | In your GPU pod's memory |
| How long it lasts | Minutes to hours, set by the provider | While the pod runs and the slot is not reused |
| What a cached token costs | A reduced price per token; some charge to write or store | Nothing per token; you pay for the GPU by the hour |
| Who else uses it | Kept per organization at the providers that document it | Only your instance |
| What can clear it | The timer, a change on the provider's side, or a changed prompt | A restart, another conversation in the slot, or a changed prompt |
| Many users at once | Handled for you | One slot on our Qwen template |
- This describes the template's settings. We have not measured cache hit rates on a running pod.
Sources: OpenLLM Buddy, GitHub
FAQ
What is prompt caching?
It lets a model keep its internal notes on text it has already read. When the next request starts with exactly the same text, the model reuses the notes and only reads what is new, which makes the answer start sooner.
Does caching change the answer?
No. A prompt cache only saves the model from re-reading. Anthropic and OpenAI both say the response is the same as without caching. A response cache is different: it returns a stored answer.
Why did my cache stop working?
Something near the start of the request changed, or the cache expired. Common causes are an edited instruction, a date stamp at the top, a changed list of tools, a switch of model or thinking setting, or a pause longer than the provider's timer.
How long does a prompt cache last?
It depends on who runs it. Anthropic's default is 5 minutes with a 1-hour option, OpenAI's is 30 minutes on recent models with longer options, and DeepSeek clears caches within hours to days. On your own server it lasts until a restart or until the memory is needed.
Is my cached prompt shared with other users?
Anthropic and OpenAI say their caches are not shared between organizations. A 2025 study found shared caches at 7 of 17 providers it audited, and several changed their systems afterward. On your own GPU, only your instance uses the cache.
Does a self-hosted model cache prompts?
Yes. llama.cpp caches by default and only processes the part of a request that differs from the last one, vLLM reuses shared openings across requests, and Ollama keeps a model loaded for five minutes by default.
How does caching work on Self Deploy?
On Self Deploy the cache lives in the memory of your own GPU pod, serves only your instance, and has no per-token price and no timer of ours: it lasts while the pod runs. Our Qwen template keeps one conversation slot, and a restart clears the cache.
Sources
- OpenLLM Buddy: Our Qwen 3.8 27B template: llama.cpp server with its default prompt cache and one slot, priced by the hour (2026-11)
- Hugging Face: Caching (how the key-value cache works) (read 2026-11)
- Anthropic: Prompt caching (read 2026-11)
- Anthropic: Claude Code: prompt caching (read 2026-11)
- Anthropic: Rate limits (cache reads and input tokens per minute) (read 2026-11)
- Anthropic: Prompt caching with Claude (2025-08-14)
- Anthropic: April 23 postmortem (2026-04-23)
- OpenAI: Prompt caching guide (read 2026-11)
- Google: Gemini context caching (read 2026-11)
- Google: Gemini API pricing (read 2026-11)
- xAI: Models and pricing (cached input) (read 2026-11)
- xAI: Prompt caching best practices (read 2026-11)
- DeepSeek: Context caching (read 2026-11)
- DeepSeek: Models and pricing (cache hit and miss) (read 2026-11)
- arXiv: Auditing prompt caching in language model APIs (Gu et al., ICML 2025) (2025-02-11)
- GitHub: llama.cpp server options (cache_prompt, slots, cache-ram, slot save) (read 2026-11)
- vLLM: Automatic prefix caching (read 2026-11)
- Ollama: FAQ (how long models stay in memory) (read 2026-11)
- Hugging Face: Manage the hub cache (downloaded model files) (read 2026-11)