Claude Code Prompt Caching Bug: How It Inflates Usage 10–20x and the Fix

ClaudeErrors & BugsUpdated May 26, 2026
Quick Answer

Claude Code versions before v2.1.34 contained two independent bugs that broke prompt caching, causing every interaction to be billed at full token cost instead of the cached rate. This inflated usage by 10 to 20 times, draining daily Pro budgets in under 20 minutes. The fix is to update Claude Code to v2.1.34 or later with 'npm update -g @anthropic-ai/claude-code'. Anthropic confirmed the bug in March 2026.

What Prompt Caching Does (and Why It Matters)

Every time you send a message in Claude Code, the system sends the full conversation context to the API:

  • The system prompt (~2,000 tokens)
  • All previous messages in the session
  • File contents that have been read
  • Tool call results

By interaction 20 in a session, this context can be 50,000+ tokens. Without caching, Claude processes all 50,000 tokens from scratch every single time — even though 95% of it is identical to the previous interaction.

Prompt caching solves this by recognizing repeated context and processing it at ~10% of the normal cost. The savings compound as sessions get longer.

How the Bug Inflated Costs

With caching broken, the cost curve looked like this:

| Interaction # | Context Size | Cost Without Caching | Cost With Caching | |--------------|-------------|---------------------|-------------------| | 1 | 5,000 tokens | 1x | 1x | | 10 | 25,000 tokens | 5x | 1.5x | | 20 | 50,000 tokens | 10x | 2x | | 30 | 75,000 tokens | 15x | 2.5x |

By interaction 30, users were paying 15x what they should have been. A session that should have consumed 10% of a Pro daily budget was consuming 150% — draining the entire allocation and hitting the limit.

Step-by-Step: Fixing the Bug

Step 1: Check Your Version

claude --version

If the output shows a version below 2.1.34, you are affected.

Step 2: Update Claude Code

For npm installations (most common):

npm update -g @anthropic-ai/claude-code

For Homebrew:

brew upgrade claude-code

Step 3: Verify the Update

claude --version

Confirm the version is 2.1.34 or later.

Step 4: Test the Fix

Start a new Claude Code session and work normally for 30 minutes. If your usage budget lasts significantly longer than before the update, the fix is working.

Why This Happened: Technical Root Cause

The prompt caching system uses a hash of the conversation context to determine if content has been seen before. Two bugs broke this:

Bug 1: Incorrect cache key computation

The cache key included a timestamp or session identifier that changed with every interaction, making every request appear unique even when the context was identical. The cache never got a "hit" because no two requests had the same key.

Bug 2: Premature cache invalidation

Even when Bug 1 was partially worked around, a second bug caused cached entries to expire after 2–3 interactions instead of persisting for the full session. This meant caching only worked for the first few messages before reverting to full-cost processing.

Both bugs needed to be fixed simultaneously — fixing only one still left caching broken.

Timeline of the Bug

  • Early 2026: Users begin reporting unusually fast limit drain on Reddit and GitHub Issues
  • March 2026: Multiple high-profile threads (330+ comments) document the issue with specific numbers ("20x max usage gone in 19 minutes")
  • March 26, 2026: Forbes reports on the pricing issues, bringing wider attention
  • March 31, 2026: Anthropic confirms the bug publicly
  • April 2026: Claude Code v2.1.34 released with the fix
  • No retroactive credits: Anthropic did not automatically refund affected users, though individual support requests were handled case-by-case

Common Mistakes to Avoid

  • Not updating Claude Code: This is the single most impactful fix — everything else is secondary if you are on an old version
  • Assuming the bug is fixed without checking your version: Auto-update is not enabled by default in all installation methods
  • Blaming the model or plan for fast drain: If your limit drains in under 20 minutes, the cause is almost certainly the caching bug, not your plan tier
  • Requesting a plan upgrade instead of updating: Upgrading from Pro to Max 5x does not fix the bug — it just gives you 5x the budget to drain 5x as fast

After the Fix: What Normal Usage Looks Like

With caching working correctly on Claude Code v2.1.34+:

  • Claude Pro: Budget lasts 2–4 hours of active coding per 8-hour window
  • Claude Max 5x: Budget lasts a full workday (6–8 hours) of moderate use
  • Claude Max 20x: Effectively unlimited for most individual developers

If your usage still feels too fast after updating, check your model setting — Opus 4 costs ~3x more than Sonnet 4 per interaction.

Related Guides

Claude · Errors & Bugs

More Claude errors & bugs guides

Browse all guides in this category to troubleshoot related issues faster.

Browse all guides →

Frequently Asked Questions

Claude Code versions before v2.1.34 had two separate bugs that prevented prompt caching from working. Prompt caching is a system that reuses previously processed conversation context at roughly 10% of the original token cost. When caching breaks, every message in an agent session is processed from scratch at full cost. For long sessions with accumulated context, this means each interaction costs 10 to 20 times more than it should. The result: users saw their entire daily Pro budget drain in 15 to 20 minutes of normal coding.

Related Guides

Continue with nearby guides in the same topic to rule out adjacent causes faster.

Claude Attachments Not Uploading or Failing to Process? Here's the Fix

Claude Pro supports file uploads up to 10 MB per file; supported formats include PDF, Word (.docx), plain text, images (PNG/JPG/GIF/WebP), and most code files. If your attachment fails or won't process, the most common causes are an oversized file, an unsupported format, a stale browser session, or a network/extension block. Clear site data for claude.ai, disable ad blockers, and retry in incognito — that resolves the issue in the majority of cases.

Claude Blank Page / White Screen: Fix Cache, Extensions, and Script Blocking

A Claude blank page or white screen is almost always caused by a stale browser cache, a script-blocking extension, or a VPN blocking WebSocket connections. Open an incognito window and sign in — if Claude loads there, clear all site data for claude.ai in your main browser and disable extensions one at a time. If Claude is blank in incognito too, disable your VPN and check status.anthropic.com for active outages.

Claude error loading chat – How to Fix

Claude's 'error loading chat' message appears when a conversation fails to sync from the server or a browser extension blocks the loading request. Refresh the page once, then try opening the conversation in an incognito window. If a specific chat refuses to load on all devices, that conversation's data may be corrupted on Anthropic's servers — start a new conversation to continue your work.

How to report a Claude bug effectively (what to include)?

Report Claude bugs at support.anthropic.com. An effective bug report includes: the exact error message, the specific steps that reproduce it (not just 'it stopped working'), your browser and OS version, whether it happens in incognito, and whether it affects all conversations or just one. Including a screenshot and the approximate timestamp speeds up resolution significantly.

How to fix Claude error while generating (stops mid-response)?

Claude stopping mid-response is usually caused by a network interruption, a browser extension blocking the streaming connection, or the response hitting a length or usage limit. The fastest fix is to refresh the page, disable extensions, and retry with a more focused request. If Claude consistently stops at the same point in a response, the content itself may be triggering a safety check — try rephrasing the request.

Claude Something Went Wrong: Causes and Fixes

The 'something went wrong' error in Claude is a generic message that covers session issues, browser problems, and temporary server errors. Start by refreshing the page and signing out then back in. If the error persists, clear your browser cookies for claude.ai and try a private window. This error almost never indicates an account problem — it is usually a temporary connection or session issue.