Prefix cache
Also called Prompt caching · Prompt cache
The provider remembers the start of your last prompt, so the next request that begins the same way is faster and much cheaper.
The prefix cache is a model provider feature that stores the processed form of the start of your prompt so the next model provider request can skip re-reading it. Because a coding session re-sends the same system prompt, tool definitions and conversation history on every request, most of each request is identical to the one before. A cache hit turns those input tokens into much cheaper cache tokens and shortens the wait before the first new token.
The catch is the word prefix. Caching works from the start of the prompt up to the first change; anything after that point is processed fresh. Change something early (edit the system prompt, reorder tools, alter an old message) and the whole cache from there onward is lost. On most providers a cache that sits idle for a few minutes is dropped, so a long coffee break can mean the next request re-pays for the full context.
Harnesses like Claude Code and Codex handle this automatically and structure requests so the stable parts come first. Your part is to keep the stable parts stable: don't churn project instructions mid-session, avoid tools that inject changing timestamps at the top of the context, and keep working steadily rather than in bursts separated by long gaps.
- Anthropic APIPrompt caching uses explicit cache breakpoints; cache reads are billed at a large discount, cache writes at a small premium.
- OpenAI APICaching is automatic for prompts past a minimum length, with discounted cached input.
- Claude CodeCaching is on by default;
/costshows how much of the input was served from cache.
“Why did the first message after lunch cost more than the whole morning?”
“Prefix cache expired. It re-processed the entire session from scratch on that one request.”
Course 01 puts every one of these terms to work: you install Claude Code, run the loop, and ship a real project — permission modes, compaction, hooks and all.
Start Course 01 →