Claude Code implements automatic prompt caching, reducing input token costs to 10%

Anthropic detailed how prompt caching functions in Claude Code. Without caching, the API would reprocess the entire history on every step: system prompts, project context, past messages, and tool outputs. The cache reuses processed prefixes and only computes changes.
Matching relies on exact prefix alignment. Claude Code sorts content into layers: system prompts and tools, then project context (CLAUDE.md, memory), and finally the dialogue. Changes in an early layer invalidate everything that follows.
Cache invalidation occurs upon changing models, effort levels, enabling fast mode, adding an MCP server to the prefix, or upgrading Claude Code. The default TTL is five minutes, with a one-hour option for subscribers. You can enable the longer TTL via the ENABLE_PROMPT_CACHING_1H=1 environment variable.
Related stories
- Claude Code sends 33k tokens before it even reads your prompt; OpenCode uses 7k
- Claude Code plugins become Claude Mods, shipping in weeks
- Function Hooks would wrap Claude Code like middleware
- Claude Tag takes the first pass at Anthropic's CI alerts
- Claude Code 2.1.247 drafts its own feedback reports
- Perf win of the day: Claude Code CLI now uses 2x less CPU at p99. Bun's garbage collector was running on a fixed tim…
Comments
No comments yet. Be the first.
Join the conversation
Sign in with Google to leave a comment. Your name and avatar come from your Google profile, and the comment appears after moderation.
