What you will be able to do
- Explain how prompt caching reuses a stable prompt prefix and when it pays off
- Choose between automatic caching and explicit cache breakpoints, and combine them
- Reason about TTLs and cache pricing, including the model-specific read multipliers
- Lay out a prompt as stable modules followed by variable content so that edits don't invalidate the cache
Key concept
Cached prompt prefix — Prompt caching does not reuse whole requests. It reuses the longest unchanged opening stretch of a request, up to a cache breakpoint. Anything you want to reuse cheaply has to sit at the front of the prompt and stay byte-for-byte the same from one request to the next.
1.Reuse starts with a stable prefix
Many prompts share most of their text across calls: the same system instructions, the same examples, the same reference material, with only the user's question changing at the end. Prompt caching lets the API skip reprocessing that shared part. When a request arrives with caching enabled, the system checks whether the prompt prefix up to a cache breakpoint is already cached from a recent query. If it is, the cached version is used, which cuts both processing time and cost. If it isn't, the full prompt is processed and the prefix is written to the cache once the response begins, ready for the next call.
The documentation lists where this pays off most: prompts with many examples, large amounts of context or background information, repetitive tasks with consistent instructions, and long multi-turn conversations. In each case a large block stays the same while a small part varies. Caching is available on every active Claude model, so the deciding question is how much of your prompt is genuinely stable, not which model you use.
Checkpoint 1 of 6· Check yourself
A request with caching enabled finds no cached entry for its prefix. What happens?
A cache miss is not an error. The request is processed in full and its prefix is written to the cache so that later requests can hit it.
“Otherwise, it processes the full prompt and caches the prefix once the response begins.”Source: platform.claude.com
Checkpoint 2 of 6· Exam question
An agentic workflow sends requests with a large tools array (15 tool definitions, cached), a cached system prompt, and growing conversation history. For one request, the developer adds tool_choice: {"type": "tool", "name": "search"} to force a specific tool call, while leaving the tools array, system prompt, and message content unchanged. What happens to prompt caching for this request?
Correct answer: A — Only the message-level cache is invalidated, so tokens up through the system prompt are still served from cache while the messages must be reprocessed.
- A. Correct. Cache invalidation cascades downward through tools, then system, then messages. A tool_choice change only invalidates the message-level cache; the tools and system caches, which sit above it in the hierarchy, remain valid and are still served from cache.
- B. Incorrect. Changing tool_choice is not equivalent to editing the tool definitions themselves; it only affects the message-level cache, not the tools-array cache.
- C. Incorrect. tool_choice does affect caching: it is one of the request properties whose change invalidates the message-level cache, so it is not entirely outside the hierarchy.
- D. Incorrect. tool_choice does not invalidate the tools-array cache; the tool definitions are unchanged. It invalidates the message-level cache instead, while the tools and system caches stay valid.
Sources1
2.Automatic caching and explicit breakpoints
You can turn caching on in two ways. With automatic caching, you add one cache_control field at the top level of the request. The system puts the breakpoint on the last cacheable block and moves it forward as the conversation grows. On each turn, everything up to the previous turn is read from cache and only the new turn is written. You never edit markers by hand, which is why automatic caching suits multi-turn chat. With explicit breakpoints, you put cache_control on individual content blocks, so you decide exactly where a cached segment ends.
Checkpoint 3 of 6· Fill the gap
Which top-level parameter turns on automatic caching in this request?
response = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
? ={"type": "ephemeral"},
system="You are a helpful assistant that remembers our conversation.",Automatic caching is a single top-level cache_control field set to {"type": "ephemeral"}. The other names are not request parameters.
Source: platform.claude.comThe two approaches can be combined. A common pattern is to put an explicit breakpoint on the system prompt, which is the reusable module, and let automatic caching follow the growing conversation. Two rules come with this. First, a request has 4 breakpoint slots, and the automatic breakpoint takes one of them. Second, if the last block already carries an explicit cache_control with the same TTL, automatic caching adds nothing. Pricing, minimum token thresholds, ordering requirements and the 20-block lookback window are identical for both approaches, because they run on the same infrastructure.
{
"model": "claude-opus-5-5",
"max_tokens": 1024,
"cache_control": { "type": "ephemeral" },
"system": [
{
"type": "text",
"text": "You are a helpful assistant.",
"cache_control": { "type": "ephemeral" }
}
],
"messages": [{ "role": "user", "content": "What are the key terms?" }]
}Sources1
3.TTLs and what caching costs
By default a cache entry lives for 5 minutes, and every hit refreshes it at no extra cost. That lifetime starts when the request begins, not when its response ends, so a long generation eats into the window before your follow-up can arrive. If requests come in less often, you can set a 1-hour TTL with "ttl": "1h". Writes at that TTL cost 2x the base input price.
{ "cache_control": { "type": "ephemeral", "ttl": "1h" } }Cache writes cost more than base input and cache hits cost much less, so caching saves money only when a prefix is read more often than it is written. The discount on reads also varies by model. Most models charge 0.1x base input for a hit, but Claude Opus 5.5 charges 0.05x, and Claude Fable 5.1 and Claude Mythos 5.1 charge 0.025x.
| Model | Base input | 5m cache write | 1h cache write | Cache hits and refreshes |
|---|---|---|---|---|
| Claude Fable 5.1 | $10 / MTok | $12.50 / MTok | $20 / MTok | $0.25 / MTok |
| Claude Opus 5.5 | $4 / MTok | $5 / MTok | $8 / MTok | $0.20 / MTok |
| Claude Sonnet 5.5 | $2 / MTok | $2.50 / MTok | $4 / MTok | $0.20 / MTok |
| Claude Haiku 4.5 | $1 / MTok | $1.25 / MTok | $2 / MTok | $0.10 / MTok |
Checkpoint 4 of 6· Check yourself
What do cache hits on Claude Opus 5.5 cost relative to its base input price?
Opus 5.5 is an exception to the standard 0.1x. Its hits and refreshes cost 0.05x base input ($0.20 against $4 per MTok).
“Cache hits and refreshes on Claude Opus 5.5 are priced at 0.05x the base input price.”Source: platform.claude.com
Sources1
4.Modular prompts: stable modules first, variables last
These sources do not describe a dedicated prompt-template syntax. They treat a modular prompt as a matter of structure: split the prompt into self-contained blocks that stay the same across calls, and keep them separate from the content that changes. Anthropic's customer-support guide works this way. It defines each body of product knowledge once as a named constant wrapped in a <static_context> tag, then repeats the pattern for each product line, and assembles the prompt from those modules.
STATIC_CAR_INSURANCE = """
<static_context>
Car Insurance Coverage:
Acme's car insurance policies typically cover:
1. Liability coverage: Pays for bodily injury and property damage you cause to others.
2. Collision coverage: Pays for damage to your car in an accident.
3. Comprehensive coverage: Pays for damage to your car from non-collision incidents.
4. Medical payments coverage: Pays for medical expenses after an accident.
5. Uninsured/underinsured motorist coverage: Protects you if you're hit by a driver with insufficient insurance.
Optional coverages include:
- Rental car reimbursement
- Roadside assistance
- New car replacement
</static_context>
"""Caching determines where those modules should go. The cache follows a fixed prefix hierarchy, tools → system → messages, and a change at any level invalidates that level and everything after it. Put the most stable modules (tool definitions, then system instructions and static context) at the front, and let per-request content come last in messages. That way the variable part changes on every call without disturbing the cached prefix. Some request settings can also break the cache even when your text is unchanged.
| Change | Invalidates |
|---|---|
| Modifying tool definitions | Entire cache (tools, system, messages) |
| Toggling web search or citations | System and messages caches |
| Changing tool_choice | Messages cache |
| Toggling images present/absent | Messages cache |
Checkpoint 5 of 6· Match them up
Match each mid-session change to the cache it invalidates
Tap a term, then the definition that fits it.
A change invalidates its own level and every level after it. Tools come first, so editing them breaks everything, while tool_choice affects only messages.
“a change at one level invalidates that level and everything after it”Source: platform.claude.com
Checkpoint 6 of 6· Exam question
A long agent session accumulates conversation turns using only automatic request-level caching. By turn 15, a cache entry exists at content block 12. By turn 25, the conversation has grown to 35 content blocks, and the current breakpoint sits on the last block. Cache reads stop matching even though the early conversation content hasn't changed. What is the best explanation and fix?
Correct answer: A — The cache lookup only scans 20 blocks backward from the breakpoint, so the block-12 entry falls outside that window; adding an explicit breakpoint further back re-establishes a match.
- A. Correct. The system checks up to 20 blocks backward from a breakpoint for a prior cache write. With the breakpoint on block 35 and the last written entry at block 12, the gap is 23 blocks, outside the lookback window, so it misses. Adding an intermediate explicit breakpoint keeps the gap within 20 blocks and restores hits.
- B. Incorrect. Automatic caching moves its breakpoint forward as a conversation grows and is designed to handle multi-turn conversations, not just a single most recent turn.
- C. Incorrect. There is no fixed block count at which cache entries are deleted outright; the miss described here is caused by the 20-block lookback window relative to breakpoint placement, not entry deletion.
- D. Incorrect. Breakpoints should be placed on the last stable block, not the first, since caching keys off the prefix ending at the breakpoint moving forward as new stable content accumulates.
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.The 5-minute cache TTL starts counting when the response finishes.Why is that wrong?
The lifetime runs from the start of the request that wrote or read the entry, so time spent streaming a long response uses up the window.
Covered in TTLs and what caching costs
2.Cache hits always cost 10% of base input on every model.Why is that wrong?
0.1x is the standard multiplier, but Opus 5.5 hits cost 0.05x, and Fable 5.1 and Mythos 5.1 hits cost 0.025x.
Covered in TTLs and what caching costs
3.Top-level automatic caching is free, on top of the four explicit breakpoints.Why is that wrong?
When it is combined with explicit breakpoints, the automatic breakpoint takes one of the 4 available slots.
Covered in Automatic caching and explicit breakpoints
4.Editing a tool definition only invalidates the tools part of the cache; the cached system prompt and messages survive.Why is that wrong?
Tools sit first in the prefix hierarchy, so modifying them invalidates the entire cache.
Covered in Modular prompts: stable modules first, variables last
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Otherwise, it processes the full prompt and caches the prefix once the response begins.”
↩︎ Reuse starts with a stable prefix“Prompt caching (both automatic and explicit) is supported on all active Claude models.”
↩︎ Reuse starts with a stable prefix“Automatic caching: Add a single cache_control field at the top level of your request.”
↩︎ Automatic caching and explicit breakpoints“Explicit cache breakpoints: Place cache_control directly on individual content blocks for fine-grained control over exactly what gets cached.”
↩︎ Automatic caching and explicit breakpoints“If the last block already has an explicit cache_control with the same TTL, automatic caching is a no-op.”
↩︎ Automatic caching and explicit breakpoints“By default, the cache has a 5-minute lifetime. The cache is refreshed for no additional cost each time the cached content is used.”
↩︎ TTLs and what caching costs“You can specify a 1-hour TTL at 2x the base input token price:”
↩︎ TTLs and what caching costs“All other models use the standard 0.1x multiplier.”
↩︎ TTLs and what caching costs“Prompt caching optimizes your API usage by allowing resuming from specific prefixes in your prompts.”
↩︎ Key concept“The lifetime is measured from the start of the request that writes or reads the cache entry, not from the end of its response.”
↩︎ Exam trap 1“Cache hits and refreshes on Claude Opus 5.5 are priced at 0.05x the base input price.”
↩︎ Exam trap 2“When used together, the automatic cache breakpoint uses one of the 4 available breakpoint slots.”
↩︎ Exam trap 3“The lifetime is measured from the start of the request that writes or reads the cache entry, not from the end of its response.”
↩︎ Prediction“Cache hits and refreshes on Claude Opus 5.5 are priced at 0.05x the base input price.”
↩︎ Checkpoint - 2.
“Then do the same for your car insurance and electric car insurance information.”
↩︎ Modular prompts: stable modules first, variables last - 3.https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-use-with-prompt-cachingOfficial docs
“a change at one level invalidates that level and everything after it”
↩︎ Modular prompts: stable modules first, variables last“The cache follows a prefix hierarchy (tools → system → messages)”
↩︎ Exam trap 4