← Reddit

Cache rewrites costed me 30% of my Fable consumption, here are the mistakes to avoid.

Reddit · coolreddy · July 11, 2026
An audit of Claude API usage patterns revealed that cache rewrites from expired sessions and silent cache invalidations were responsible for 30% of total consumption waste. Cache expires after one hour of inactivity, forcing expensive rewrites that cost the equivalent of 20 normal API calls, with additional invalidations occurring when tools are loaded mid-session, models or effort levels are switched, or Claude code is updated mid-work. The author reduced this waste by implementing keepalive pings to refresh cache in idle sessions before expiration.

Detailed Analysis

A Reddit user in the r/ClaudeAI community published a detailed cost-accounting breakdown showing how Anthropic's prompt-caching system can silently inflate the price of long-running Claude Code sessions by roughly 30 percent if left unmanaged. The post walks through the underlying economics: every conversational turn resends the full session history to the model, and prompt caching exists specifically to make that repetition affordable by storing the history server-side and charging a fraction of the normal input rate for subsequent reads. Using pricing figures of $10 per million input tokens, $1 per million for cache reads, and $12.50–$20 per million for cache writes (depending on the 5-minute versus 1-hour cache window), the author demonstrates that a heavy 400k-token session normally costs about $0.40 per turn when reading from cache, but jumps to roughly $8 the moment the cache expires and must be rewritten — the equivalent of 20 normal turns burned in a single message.

The practical value of the post lies in its enumeration of the "silent" triggers that invalidate a cache and force an expensive rewrite: letting a session sit idle past the one-hour cache window, loading new tools or MCP servers mid-conversation (which alters the prompt prefix), switching models mid-session, toggling between reasoning "effort levels" or fast modes, and even updating the Claude Code CLI itself while sessions are still open. Each of these actions changes the underlying token sequence the model has cached, forcing a full, premium-priced rewrite rather than a cheap cache read. For users running multiple parallel Claude Code sessions — a common workflow among developers using agentic coding tools — these invalidations compound quickly, since a single idle break can trigger cache rewrites across every open session simultaneously.

This matters because it exposes a gap between how Anthropic's caching mechanism is documented and how it actually behaves under real-world, multi-session developer workflows. Prompt caching is one of the primary levers Anthropic and other frontier labs use to make long-context, agentic use cases economically viable; without it, the cost of maintaining large working contexts across iterative coding sessions would be prohibitive. But the mechanism's fragility — invalidated by tool changes, model switches, or even routine version updates — means that users who aren't explicitly optimizing around its constraints can unknowingly erase most of the savings caching is meant to provide. The author's workaround, a custom "skill" that pings idle sessions with large contexts just before the one-hour cache window closes, is a clever but telling example of users having to build their own tooling to compensate for cost mechanics that aren't surfaced clearly in the product itself.

More broadly, this post reflects a maturing phase in how developers relate to agentic AI coding tools: usage optimization is becoming its own discipline, alongside prompt engineering and context management. As Claude Code and similar tools push toward longer sessions, larger contexts, and more autonomous multi-step workflows, the economics of caching, context windows, and model switching increasingly determine real-world usability and cost, not just raw model capability. Community-generated cost audits like this one — grassroots, empirical, and shared openly — are filling a documentation gap, effectively crowdsourcing operational best practices that labs like Anthropic have not yet made fully transparent or automated. It also signals growing user sophistication: developers are treating token economics with the same rigor as cloud infrastructure cost optimization, suggesting that as agentic AI becomes embedded in daily engineering workflows, FinOps-style discipline around AI usage will become a standard part of the toolkit.

Read original article →