Defeating the 5-Minute Prompt-Cache Cliff
Practical safeguards for the financial impact of Anthropic’s server-side prompt-cache expiration window.
The Caching Problem
Anthropic’s server-side cache drops structural context after a period of silence — by default, 5 minutes. Stepping away from the keyboard for longer than that means the next prompt pays for a “cache miss”: a slower, full-priced turn that re-sends the conversation’s structural context instead of reusing the cached version.
Force a Longer Cache TTL (Tier-Dependent)
If the account tier supports it, requesting a longer cache window (up to an hour, instead of 5 minutes) stretches how long a break can be before the next turn pays for a cold start.
Open the shell profile (~/.bashrc, ~/.zshrc, or the equivalent Windows environment variable settings) and add:
export ENABLE_PROMPT_CACHING_1H=1
This requests the longer-lived cache flag on session turns. Whether it actually extends the window depends on account tier support.
The “Clean Break” Routine
If the account tier doesn’t support the longer TTL, adapt the workflow around the 5-minute window instead. Leaving a large conversation history sitting idle while stepping away for a break is the expensive case to avoid.
Before pausing to read documentation, manually test something, or take a break:
- Run
/compact(compress the session history into a summary) or/clear(wipe it) before stepping away. - Close the terminal session.
- Start fresh when returning.
Re-reading a pre-cleared or pre-compacted history on the next cold start costs far less than re-reading an un-compacted backlog of many old messages.
Cap the Context-Window Ceiling
If a cache miss happens mid-conversation, Claude Code can attempt to re-read a very large amount of context at once. A safety ceiling limits the maximum amount of data Claude is allowed to process per turn:
export CLAUDE_CODE_DISABLE_1M_CONTEXT=1
This caps the maximum context limit to the smaller default tier instead of the full extended window, which bounds the worst-case cost of a cold start.
Check Cache Behavior in Local Logs
To see whether the cache is holding or expiring during a working session, check the local session-metrics logs for the cache-related fields Claude Code records per turn (consult the CLI’s own documentation for the exact log location and field names, since this is implementation detail that can change between versions). A session dominated by cache-write activity means the cache is expiring frequently; a session dominated by cache-read activity means it’s staying warm.