Guide
Claude Code prompt cache: TTL, hit rate, and idle gaps
Updated 2026-11-14
Most of what Claude Code sends on each turn is the same as last turn: the system prompt, tool definitions, your CLAUDE.md, and the conversation so far. The prompt cache lets that repeated prefix be read back cheaply instead of paid for in full every time. How well the cache works for you shows up directly in your token usage.
How the cache works in Claude Code
- Cache write. The first time a prefix is sent, it is written to the cache. At API rates a write costs more than plain input: 1.25x for the default five-minute cache, 2x for the one-hour cache.
- Cache read. Later turns that send the same prefix read it back at a tenth of the input price on most models.
- New input. Anything after the cached prefix, such as your new message and fresh tool output, is billed as normal input.
Your session logs record all three on every turn, as
cache_creation_input_tokens,
cache_read_input_tokens, and input_tokens. See
the token usage guide for where the
logs live.
Cache TTL: the five-minute clock
The default cache lifetime (TTL) is five minutes, and each read restarts the clock. Keep working and the prefix stays warm. Step away for longer and the next turn has to write the whole prefix again, at the write price, even though you already paid to cache it once.
One long break costs little. The pattern that adds up is many of them: a session left open over lunch, then resumed, then left again. CostClaw measures this from the timestamps in your logs. It finds every turn that followed the previous one by more than the cache lifetime and had to rewrite the prefix, and it reports the hour-plus gaps as a separate recoverable item.
The practical fix is cheap: if you are about to step away from a long session, compact it or finish it first, so the prefix you return to is small.
What your cache hit rate means
Cache hit rate is the share of input tokens served from the cache: cache reads divided by all input (new input plus cache writes plus cache reads). In long interactive sessions the large majority of input should come from cache reads. A low rate usually points at one of three causes:
- Many short sessions, each paying to build a cache it barely reads.
- Frequent idle gaps longer than the cache lifetime.
- A prefix that keeps changing, for example a CLAUDE.md that carries dated status lines or is edited between sessions.
A cache write is not waste
It is tempting to count every cache write as overspend. That is wrong: a write is the price of having a cache, and no read happens without one first. One read already beats paying full input twice. What is worth chasing is uncached input and writes that were never read back. That is exactly what the CostClaw audit counts as recoverable, and it lists the writes that earned their reads separately as working cost.