What is prompt (prefix) caching, and why is it one of the biggest cost levers available?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Prefill work depends only on the tokens processed so far, so if two requests share an identical token prefix, the KV cache computed for that prefix is reusable. Prompt caching stores it and skips recomputation. The canonical wins: a long system prompt + tool definitions shared by every request; multi-turn conversations (each turn re-sends the whole history - the previous turns are a shared prefix); many questions over the same long document; agent loops re-sending large contexts every step.
Full worked answer with diagram
Prefill work depends only on the tokens processed so far, so if two requests share an identical token prefix, the KV cache computed for that prefix is reusable. Prompt caching stores it and skips recomputation. The canonical wins: a long system prompt + tool definitions shared by every request; multi-turn conversations (each turn re-sends the whole history - the previous turns are a shared prefix); many questions over the same long document; agent loops re-sending large contexts every step.
Self-hosted: vLLM does hash-based automatic prefix caching over KV blocks; SGLang's RadixAttention keeps a radix tree of cached prefixes and its scheduler routes matching requests to them. Cache hits cut TTFT dramatically (prefill collapses to the uncached suffix) and free compute.
Provider APIs monetise the same mechanism: cached input tokens are billed at a steep discount, and on the newest models writes carry a premium. As of late 2026:
- Anthropic offers automatic caching (one top-level
cache_controlthat moves forward as the conversation grows) as well as explicit breakpoints. Writes cost 1.25× base input for the 5-minute refreshing TTL or 2× for 1 hour. Reads cost 0.1× on most models, 0.05× on Opus 5.5 and Sonnet 5.5, and 0.025× on Fable 5.1 and Mythos 5.1. - OpenAI caches implicitly by default with a 1,024-token minimum. On GPT-5.6 and later you can also place explicit breakpoints (
prompt_cache_breakpoint, up to four cache writes per request). Writes cost 1.25× input for the default 30-minute lifetime and 2.5× for the 12-hour lifetime added in October 2026. Reads cost 0.1×, or 0.05× on GPT-6.1 Sol and Terra. GPT-5.5 and earlier stay implicit-only with no write fee. - Gemini caches implicitly by default on 2.5 and newer. Explicit context caching exists only on supported Gemini 3 and 2.5 models, not on Gemini 4 Argon and later, where implicit cache hits are 95% off.
Exact multipliers and TTLs change often, so read the current price page rather than memorising them. The write premium means a prefix that is written and never re-read costs more than no caching at all. For an agent re-sending a 20K-token context 30 times per session, caching is the difference between paying for ~600K input tokens and ~600K mostly-discounted ones - often the single largest line-item saving available with zero quality impact.
The engineering discipline it imposes: stable prefix first, variable content last. Any changed byte invalidates everything after it - so no timestamps/request IDs early in the system prompt, deterministic tool-definition ordering, and append-only conversation structure. Cache hit rate belongs on your cost dashboard.
Worth sketching. Drawing the hit path makes the prefix discipline self-evident: anything volatile early moves every request onto the miss branch.
flowchart TD
R["Incoming request tokens"] --> M["Longest matching cached prefix?"]
M -->|"hit: system prompt, tools, history"| S["Reuse KV blocks,<br/>prefill only the new suffix"]
M -->|"miss: a byte changed near the front"| F["Full prefill, then store"]
S --> G["TTFT collapses, cached input billed at a discount"]
F --> G
What a good answer covers
- Prefill work depends only on the tokens processed so far, so if two requests share an identical token…
- Prompt caching stores it and skips recomputation
- The canonical wins: a long system prompt + tool definitions shared by every request; multi-turn…
- Self-hosted: vLLM does hash-based automatic prefix caching over KV blocks; SGLang's RadixAttention keeps…
- Cache hits cut TTFT dramatically (prefill collapses to the uncached suffix) and free compute
Key terms: Anthropic · OpenAI · Gemini
In the glossary: Prompt caching · vLLM · Prefix caching · SGLang · RadixAttention · TTFT
Interviewer follow-ups to expect
Why does inserting the current date at the top of a system prompt destroy caching?
How does prefix caching interact with per-user personalisation?
What's the difference between this and semantic caching?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep