What does prefix caching store, and which workloads benefit most?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Explain what provider prompt (prefix) caching actually caches and the workload shape that makes it pay off.
Prefix caching stores the KV state of a stable leading prompt segment so repeat calls skip prefill over it; it pays off when many requests share a large, identical head.
Imagine a teacher who reads the same long set of class rules aloud before every lesson. Instead of re-reading the whole thing each time, she records it once and just plays the recording, then adds the day's new material live. Prompt caching does that for an LLM. The long, unchanging part at the start of your prompt — the standing instructions, a shared document — gets processed once and saved. Later requests that begin with the exact same opening skip re-processing it and pick up from where the saved part ends. You save time and money on the repeated part, but only if it stays word for word the same and sits at the very front.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Spend 6-8 minutes on what gets cached (KV state of the prefix), the exact-prefix requirement, the workloads that benefit, and the cost discount.
| Aspect | Prefix caching | HTTP-style response cache |
|---|---|---|
| What's stored | KV state of the prompt prefix | The full response body |
| What's saved | Prefill compute + cost on the prefix | The entire computation |
| Output | Generated fresh every call | Returned identical from cache |
| Hit condition | Identical leading prefix | Identical full request/key |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Thinking caching stores the model's answer like an HTTP cache — it stores the KV state of the prompt prefix, so it speeds prefill but still generates a fresh output every call.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.