Why does Claude Code lose its prompt cache?
Updated 25 November 2026
Claude Code sends your whole conversation with every request and reads most of it back from a prompt cache at a much lower rate. When that cache is lost, the next request reprocesses everything at full price. Two things cause it: a pause longer than the cache lifetime, and a few actions that change the start of the request.
How long does the cache last?
Five minutes or one hour after the last request that used it, and every hit resets the timer. By default the main conversation gets one hour on a Claude subscription within its included usage, and five minutes with an API key, a cloud provider or usage credits. Subagents and compaction requests get five minutes in most setups.
So the expensive moment is the first message after a break: back from lunch to a long session, and the whole history is read in again uncached.
Which actions reset the cache?
- Switching models: each model has its own cache, including
opusplanmoving in and out of plan mode. - Changing effort level on many models, and turning fast mode on or off.
- Adding or removing MCP tools when tool search is off, or removing a tool on purpose, for example with a deny rule or
/mcp. - Compacting: the history is replaced by a summary, so its cache is rebuilt, though for a much shorter history.
- Many images: when old images are dropped to stay under the limit, the conversation is reprocessed from there.
- Upgrading Claude Code: the first session after a restart builds its cache from the top.
Which actions are safe?
Editing your files or CLAUDE.md, changing permission mode or output style, running skills and commands, /recap, /rewind and starting a subagent all keep the cache.
What helps?
- Before a long break: run
/compactwhile the cache is still warm, or plan to start a fresh session afterwards. - Pick model and effort at the start of a task rather than in the middle of it.
- If you pause often on an API key: consider
promptCacheTtlset to1h.
How do I see how often it happens to me?
Inside a session, /usage shows the Prompt cache line with misses and whether the cache is warm. Across past sessions, Quotopsy counts each rebuild, says whether it followed an idle gap, and estimates what it cost:
npx quotopsy
The usage limit guide covers the other common causes.
Questions
How long does the Claude Code prompt cache last?
Five minutes or one hour after the last request that used it. On a Claude subscription within its included usage, the main conversation gets one hour by default; with an API key, a cloud provider or usage credits it gets five minutes. Each cache hit resets the timer.
Can I make the cache last longer?
Yes. Set promptCacheTtl to 1h in your settings (Claude Code 2.1.242 or later). The one-hour cache charges more for cache writes, so it pays off when you pause often and costs more when you never do.
Does editing CLAUDE.md break the cache?
No. Claude Code reads it at session start, so a mid-session edit keeps the cache and takes effect after /clear, /compact or a restart.
How do I see my cache misses?
Run /usage: the Prompt cache line shows hits, misses and whether the cache is warm, and from 2.1.260 a likely cause for the last miss. npx quotopsy counts rebuilds across past sessions and estimates what they cost.
Sources
Read on 25 November 2026. Quotopsy is an independent project, not made or endorsed by Anthropic.