Prompt caching reuses prefill KV for a byte-identical prefix, so cached input bills at roughly 10 percent of normal; any variable content above stable content breaks the hit.
Imagine reading the same long instruction sheet aloud before every conversation. The first time you read it slowly, but you remember it, so next time you can skip straight to the new question. Prompt caching is that memory for the model. When the start of your prompt is exactly the same as before, the provider reuses the work it already did and charges you a small fraction for those repeated tokens. But the trick only works from the very beginning. If you change even one word near the top, like stamping today's date, the model has to reread everything below it from scratch and you pay full price again. So you keep the unchanging part at the front and put the part that changes at the very end.
Detailed answer & concept explanation~8 min readEverything 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. 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.
3 min: why prefill reuse enables the discount + cached read at ~10 percent and the write premium + byte-identical prefix matching + stable-first prompt layout + TTFT win and what silently breaks a hit.
Real products, models, and research that use this idea.
- Anthropic's Claude Opus 4.7 prompt caching bills cache reads at roughly 10 percent of input rate, with a one-time write premium, controlled by explicit cache breakpoints.
- OpenAI's GPT-5.5 applies automatic prefix caching for repeated prompt prefixes above a token threshold, discounting the cached input segment.
- Google's Gemini 3.1 Pro offers both implicit and explicit context caching so long stable documents are billed at a reduced cached rate.
- RAG agents built on LangChain place the system prompt and tool schemas first so cache hits survive across thousands of per-query retrievals.
- vLLM and SGLang expose automatic prefix caching that shares cached KV blocks across requests with common system prompts on self-hosted stacks.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does cached input cost roughly 10 percent rather than zero?
QWhy is there a write premium on the first cached request?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Putting a per-request value like a timestamp, session ID, or freshly retrieved chunks above the stable system prompt. It poisons the prefix and forces full-price prefill on everything below.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.