# 29.7 Caching by how often content changes (/building-ai-workers/model-selection-and-cost/caching-by-how-often-content-changes)

---
type: Document
title: "29.7 Caching by how often content changes"
description: "Where single, layered and rolling breakpoints go on the extraction's request, what limits and breaks the cache, and how a breakpoint is checked."
status: stable
order: 329.07
ksor:
  owner: team:panaversity
  audience:
    - public
  approval:
    by: process:panaversity
    at: 2026-11-30T10:58:07Z
chapter: '29'
part: III
expert_status: manager
concepts: [ "29.7" ]
last_verified: '2026-11-30'

sources:
  - id: anthropic-cost-and-intelligence
    title: Optimizing for cost and intelligence, Anthropic (verified 2026-11-30)
    resource: https://platform.claude.com/docs/en/about-claude/models/optimizing-for-cost-and-intelligence
  - id: anthropic-pricing
    title: Pricing, Anthropic (verified 2026-11-30)
    resource: https://platform.claude.com/docs/en/about-claude/pricing
  - id: anthropic-effort
    title: Effort, Anthropic (verified 2026-11-30)
    resource: https://platform.claude.com/docs/en/build-with-claude/effort
  - id: anthropic-effort-per-message
    title: Effort per message, Anthropic (verified 2026-11-30)
    resource: https://platform.claude.com/docs/en/build-with-claude/effort-per-message
  - id: anthropic-prompt-caching
    title: Prompt caching, Anthropic (verified 2026-11-30)
    resource: https://platform.claude.com/docs/en/build-with-claude/prompt-caching
  - id: anthropic-cache-diagnostics
    title: Cache diagnostics (Anthropic, verified 2026-11-30)
    resource: https://platform.claude.com/docs/en/build-with-claude/cache-diagnostics
  - id: anthropic-task-budgets
    title: Task budgets (Anthropic, beta, verified 2026-11-30)
    resource: https://platform.claude.com/docs/en/build-with-claude/task-budgets
generated:
  at: 2026-11-30T10:58:07Z
  by: esl-rewrite/1.2.0+ksor.1
trust_tier: unverified
build_id: sha256:d6ce3f28a2cf8e492a60bae1b426b7cc6466e35e83d70c3b9763db2c55009f4b
dirty: true
ksor_version: 0.0.60
---

**In everyday life.** A street cook sells three dishes. Every morning she makes one big pot of base sauce, which goes into every dish all day. For each dish she mixes its own spices once, and keeps them ready. Each order is cooked fresh, because each customer wants something different. She never cooks the base sauce again for a single order. In this section, the base sauce is the tools and the shared rules, and the spice mix is a company's own block. The order is the invoice, and each pot she keeps ready is a cache breakpoint.

**What you will learn.** You practice this in Lab 29, Task 2.

- What does the extraction send, block by block?
- Where do single, layered and rolling breakpoints go?
- What limits a breakpoint?
- When does the one-hour cache pay?
- What breaks the cache?
- How do you check a breakpoint?

**Why it matters.** Every invoice resends the same tools and rules. Without a breakpoint, Brightline pays the full input price for them again on every request.

**At work.** Tuesday, 10:15 a.m. The extraction is the largest line, and little of its input is read from the cache. You open the request the extraction step sends ([25.2](../prompts-and-structured-output/system-or-user.md)) and write beside each block how often it changes.

[21.12](../agent-loop-by-hand/tokens-caching-and-what-a-call-costs.md) taught what caching is and the two rules that keep it working: put what never changes first, and never change it between requests. This section adds where to put the markers.

### What does the extraction send, block by block?

**Two requests for each invoice. The second repeats the first, then adds the invoice.** Since Lab 25, the extraction asks for the invoice with the tool `get_invoice`, and answers after the tool result ([Lab 25](../prompts-and-structured-output/lab.md)). These are its blocks:

| Block | What it holds | How often it changes |
| --- | --- | --- |
| 1. Tools | The definition of `get_invoice` | With a new prompt version |
| 2. The system prompt | The operator's rules for every invoice, with the five allowed payment terms | With a new prompt version |
| 3. The task turn | "Extract INV-8340" | For each invoice |
| *Request 1 ends here. The model answers with a `get_invoice` call.* | | |
| 4. The model's call | The `get_invoice` call from request 1 | For each invoice |
| 5. The tool result | The invoice, as data | For each invoice |
| 6. A system message | The run date | Each day |
| *Request 2 ends here. The model answers with the invoice's fields.* | | |

The API reads a request from its start: the tools first, then the system prompt, then the turns. A cache hit needs a start that is 100% identical.[^anthropic-prompt-caching]

### Where do single, layered and rolling breakpoints go?

**A breakpoint goes at the end of each block that changes more slowly than what comes after it.** A `cache_control` marker on one block is a **cache breakpoint**. The API writes everything up to that block to the cache, and a later request that starts the same way reads it.[^anthropic-prompt-caching] Three placements follow from how often the blocks change:

- **Single placement.** One breakpoint after the shared rules, block 2. Every invoice of the morning starts with the same tools and rules, so every invoice after the first reads them.
- **Layered placement.** A second breakpoint after a block that changes at its own pace. Each company's allowed terms and vendor rules would move into a block of their own, after the shared rules. Brightline's and Cedar Ridge's extractions then share the first layer, and each reuses its own second.
- **Rolling placement.** A breakpoint at the end of request 1, on the task turn. Request 2 sends the same blocks with the same markers, so it reads everything request 1 wrote. It pays full price only for the model's call, the invoice and the date.

<!-- EDITOR: the layered placement is proposed (spec, appendix point 16). Today's extraction has no per-company block, so moving each company's terms and vendor rules into one is a new story fact for specs/labs/part-2-facts.md, and a prompt change that Chapter 24's suite must pass before it ships. The other option: teach the layered placement on the month-end review's conversation, and keep the extraction single and rolling. -->

The run date stays after the last breakpoint. Anthropic's advice is to put text that changes with each request, such as timestamps, after the last breakpoint.[^anthropic-cost-and-intelligence] Section 25.2 already put the date in a system message after the invoice, so no change is needed.

<!-- FIGURE 29.3: "Breakpoints by how often content changes." Two tall stacks of blocks side by side, read top to bottom, headed "Request 1" (left) and "Request 2" (right). Request 1 holds four blocks: "tools: get_invoice" and "shared rules, with the five terms" (both shaded gold, labeled on the left "change only with a prompt version"), then "this company's terms and vendor rules" (shaded light gold with a dashed border, labeled "per company: proposed"), then "task turn: extract INV-8340" (white, labeled "each invoice"). Request 2 repeats the same four blocks, then adds three: "the model's get_invoice call", "tool result: the invoice, as data" (both white, labeled "each invoice") and "system message: the run date" (grey, labeled "each day"). Three horizontal markers cross the stacks, each a short bar with a label: after "shared rules" in both stacks, "single"; after the company block in both stacks, "layered"; after "task turn" in both stacks, "rolling". A curved arrow runs from the "rolling" marker on Request 1 to the same marker on Request 2, labeled "written by request 1, read by request 2". A bracket on the right of Request 2 covers its last three blocks and is labeled "after the last breakpoint: paid at full input price". Below both stacks: "Put a breakpoint where content starts changing faster." -->

*Figure 29.3. Each breakpoint sits where the next block changes faster. Request 2 reads what request 1 wrote.*

### What limits a breakpoint?

**A count, a reach, a minimum length, a price, and timing.** The page's own limits:[^anthropic-prompt-caching]

- **Four breakpoints a request.** Automatic caching, one setting on the request that places a breakpoint for you, uses one of the four. The extraction's three placements fit.
- **A reach of 20 blocks.** A breakpoint looks back up to 20 blocks for an earlier write. A run of tool calls, or of tool results, in a row counts as one position. Writes happen only at breakpoints, so looking back finds what an earlier breakpoint wrote, not text that only stayed the same. The extraction's requests are short. A long conversation, such as the month-end review, needs a breakpoint at least every 20 blocks.
- **The minimum length.** On Sonnet 5.5 and Haiku 5.5, the part before a breakpoint must be at least 512 tokens. A shorter part is processed uncached, with no error. Read `cache_creation_input_tokens` on the first request: zero means nothing was written.
- **The price.** A five-minute write costs 1.25 times the input price, a one-hour write 2 times. A read costs 0.05 times on Sonnet 5.5, which is $0.10 per million tokens.[^anthropic-pricing] A five-minute entry pays for itself after one read, and a one-hour entry after two.[^anthropic-pricing]
- **The timing.** "A cache entry only becomes available after the first response starts."[^anthropic-prompt-caching] Requests sent together all miss. Send the morning's first invoice alone, and send the others once its response has started.

### When does the one-hour cache pay?

**When the gaps between requests are often longer than five minutes, and rarely longer than an hour.** A five-minute entry is renewed free each time it is read. A one-hour entry is asked for with `"ttl": "1h"`. Both lifetimes count from the start of the request, and a longer-lived entry must come before a shorter one in the request.[^anthropic-prompt-caching] Anthropic gives a measure. The hour pays when "about 1 turn in 20 follows a pause between 5 minutes and an hour and few gaps run over an hour". It breaks even, neither saving nor losing money, near 1 turn in 30. On Sonnet 5.5, a five-minute entry kept alive by a request every four minutes can cost less.[^anthropic-cost-and-intelligence]

The morning extraction sends invoices one after another, so the five-minute entry stays alive. The batch in [29.8](realtime-or-batch.md) is the other case. Its second round waits for the first to end, so it uses the one-hour cache.

### What breaks the cache?

**Any change before a breakpoint, and some settings that change nothing in the text.** The cache is built in the order tools, system prompt, messages, and a change breaks its own level and every level after it:[^anthropic-prompt-caching]

| Change | What it breaks |
| --- | --- |
| The tool definitions | Everything |
| Turning web search or citations on or off, or the `speed` setting | The system prompt and the messages |
| `tool_choice`, or adding or removing an image | The messages |
| The thinking settings | The messages, and on some models the tools and system prompt too |
| Top-level effort | It "can invalidate all or part of the prompt cache". Setting it to the model's default does not.[^anthropic-effort] A per-message effort change, in beta, keeps the cached start[^anthropic-effort-per-message] |
| Thinking blocks dropped from earlier turns | The messages |
| The task budget's value ([29.9](token-budgets-and-a-saving.md)) | Entries made under the old value no longer match[^anthropic-task-budgets] |
| The model | Everything. "The cache is per-model"[^anthropic-cache-diagnostics] |

So never switch the model, the tools or the thinking settings in the middle of a conversation you want cached. A request on Haiku 5.5 reads nothing that Sonnet 5.5 wrote.

### How do you check a breakpoint?

**By the cache share and the usage fields, never by the suite.** A breakpoint changes what a request costs, not the text the model reads, so the output cannot change because of it. Running Chapter 24's suite would spend money to measure nothing. Rerun one day's invoices with the breakpoints, then read three things:

1. The first request writes: `cache_creation_input_tokens` is above zero.
2. The requests after it read: `cache_read_input_tokens` is above zero, and the cache share rose.
3. If the share did not rise, cache diagnostics names the earliest change ([29.6](reading-a-usage-report.md)).

At 10:15 you add one breakpoint after the tools and rules, and one at the end of each first request. A rerun of Monday, May 3's invoices raises the extraction's cache share. The suite is not run.

<!-- OPEN: recorded run. The cache share before and after the breakpoints comes from the recorded rerun of May 3's invoices (spec, appendix point 15). -->

**The operating rule:** place a breakpoint wherever the next block changes faster, keep per-request text after the last one, and check it by the cache share.

[^anthropic-prompt-caching]: Prompt caching, Anthropic, read November 30, 2026.
[^anthropic-cost-and-intelligence]: Optimizing for cost and intelligence, Anthropic, read November 30, 2026.
[^anthropic-pricing]: Pricing, Anthropic, read November 30, 2026.
[^anthropic-effort]: Effort, Anthropic, read November 30, 2026.
[^anthropic-effort-per-message]: Effort per message, Anthropic, read November 30, 2026.
[^anthropic-task-budgets]: Task budgets, Anthropic, read November 30, 2026.
[^anthropic-cache-diagnostics]: Cache diagnostics, Anthropic, read November 30, 2026.
