Prompt Caching
# Guide 08: Prompt Caching
> **Prompt caching is the single largest automatic discount on your Claude Code bill.** It reduces input token costs by up to 90% on repeated content -- and it happens without any configuration. Understanding how it works, what breaks it, and how to maximize hit rates can save you hundreds of dollars per month.
---
## Table of Contents
- [How Prompt Caching Works](#how-prompt-caching-works)
- [The Prefix Matching Rule](#the-prefix-matching-rule)
- [Cache Pricing by Model](#cache-pricing-by-model)
- [Cache Write vs Cache Hit](#cache-write-vs-cache-hit)
- [What Gets Cached in Claude Code](#what-gets-cached-in-claude-code)
- [What Breaks the Cache](#what-breaks-the-cache)
- [Cache TTL and Economics](#cache-ttl-and-economics)
- [Standard vs Extended TTL](#standard-vs-extended-ttl)
- [Breakeven Math](#breakeven-math)
- [Maximizing Cache Hit Rate](#maximizing-cache-hit-rate)
- [ROI Calculations](#roi-calculations)
- [Scenario 1: 50-Turn Session with Good Caching](#scenario-1-50-turn-session-with-good-caching)
- [Scenario 2: 50-Turn Session with Poor Caching](#scenario-2-50-turn-session-with-poor-caching)
- [Comparison Table: Cache Hit Rate Impact](#comparison-table-cache-hit-rate-impact)
- [Advanced Patterns](#advanced-patterns)
- [Common Mistakes](#common-mistakes)
- [Key Takeaways](#key-takeaways)
---
## How Prompt Caching Works
Claude's API uses prompt caching to avoid reprocessing content it has already seen. The mechanism is straightforward: when the **prefix** of a prompt matches a previous request, the matching portion is served from cache at a steep discount instead of being reprocessed at full price.
This is not a semantic cache. It is an exact prefix match. The cache checks whether the beginning of the current request is byte-for-byte identical to a recent request. If the first 50,000 tokens of your current turn match the first 50,000 tokens of the previous turn, those 50,000 tokens are cache hits. The moment a single token diverges, everything after that point is a cache miss.
### The Prefix Matching Rulewhen to use it
Community prompt sourced from the open-source GitHub repo Sagargupta16/claude-cost-optimizer (MIT). A "Prompt Caching" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.
tags
productivitycommunitydeveloper
source
Sagargupta16/claude-cost-optimizer · MIT
more in Productivity
Productivity✓ tested
Summarize a doc into decisions & actions
chief of staff who extracts what to DO, not just what was said
Productivity✓ tested
Draft a reply to a hard email
calm, direct communicator who de-escalates without caving
Productivity✓ tested
Turn a brain-dump into a weekly plan
planning coach who protects your focus, not just your calendar