◉CLAUDE LABJP
●2.1.301 — Adds the vim % motion, LaTeX math rendering in the VS Code panel, and a retry-watchdog limit for usage-limit waits (10/15)●2.1.299 — Conversations over 200K tokens left idle about 54 minutes get compacted; MCP allow rules now match only the server they name●SONNET 4.5 — Retires on the Claude API on 11/30, 45 days left. Migrate to Sonnet 5.5●WINDOWS — Reports say hooks break silently only on Japanese-locale Windows; check the character encoding first●FAST MODE — Opus 5.5 fast mode is out of research preview and no longer needs the beta header (10/15)●NEW — I Put a Ten-Line Promise File at the To…●2.1.301 — Adds the vim % motion, LaTeX math rendering in the VS Code panel, and a retry-watchdog limit for usage-limit waits (10/15)●2.1.299 — Conversations over 200K tokens left idle about 54 minutes get compacted; MCP allow rules now match only the server they name●SONNET 4.5 — Retires on the Claude API on 11/30, 45 days left. Migrate to Sonnet 5.5●WINDOWS — Reports say hooks break silently only on Japanese-locale Windows; check the character encoding first●FAST MODE — Opus 5.5 fast mode is out of research preview and no longer needs the beta header (10/15)●NEW — I Put a Ten-Line Promise File at the To…
Articles/API & SDK
⬡ API & SDK/2026-06-24Advanced

I Edited One Line of a Tool Description and the Whole Prompt Cache Rebuilt — Where to Place cache_control Breakpoints

Hit rate suddenly flatlined at zero because a volatile block sat upstream of stable ones. This walks through how prefix-cache cascade invalidation works, how to reorder blocks from stable to volatile, and where to spend your four cache_control breakpoints — with code and decision tables.

claude-api83prompt-caching15cost-optimization31context-management5performance4

✦ Premium Article

One morning, going over the API costs of the automated publishing pipeline I run across four sites, I stopped. The request volume and input token counts had barely moved, yet cache_read_input_tokens was pinned near zero. The week before, most of the prefix had been served from cache.

Only one change came to mind. I had tweaked a single line in a tool's description — just smoothing out the wording. That one line had dragged the system prompt and the few-shot examples below it into a full cache rebuild. The cost numbers reminded me of something obvious: prompt caching does not work per "block." It works on the contiguous match from the front — the prefix.

This article is about why that cascade invalidation happens, and how ordering your blocks and placing your breakpoints can keep the cache on the stable parts alive even when you edit the volatile ones.

A prefix cache matches "from the front," not per block

This is the easiest part to misread. Marking a block with cache_control does not cache that block in isolation. What gets cached is the entire contiguous prefix from the start of the request up to and including the breakpoint.

Requests are concatenated in a fixed order: tools → system → messages. On every call, matching runs from the front of this concatenated sequence, and the cache serves up to the longest prefix that exactly matches the previous request. One differing character anywhere, and everything from that point onward stops matching and is rewritten (cache creation).

That is exactly what bit me. tools sits at the very top. Editing one line of a tool definition broke the match partway through tools, so the system and messages that followed became "non-matching prefix" too. I had changed nothing downstream, yet the upstream edit took everything down with it. That is cascade invalidation.

The flip side is encouraging: just by putting volatile things downstream and stable things upstream, you can prevent most of this collateral damage.

Read the four numbers in usage correctly

To judge whether a reordering helped, you have to read usage well. These are the four I check every time.

FieldMeaningRough billing feel
cache_creation_input_tokensTokens newly written to cachePricier than base input (about 1.25x for 5-min TTL, ~2x for 1-hour TTL)
cache_read_input_tokensTokens served from cacheCheap — about 0.1x of base input
input_tokensUncached raw inputBase price
output_tokensGenerated outputOutput price

In a healthy state, the second request onward should show a large cache_read_input_tokens and a small cache_creation_input_tokens (just the changed tail). During my incident it was reversed: cache_creation_input_tokens ballooned every call and cache_read_input_tokens was near zero. I treat "creation keeps showing up every call" as a sign that something upstream changes every call — that is the first thing I suspect.

def cache_health(usage) -> dict:
    created = usage.cache_creation_input_tokens or 0
    read = usage.cache_read_input_tokens or 0
    fresh = usage.input_tokens or 0
    cacheable = created + read
    # of the cacheable portion, how much was actually read
    read_ratio = read / cacheable if cacheable else 0.0
    return {
        "read_ratio": round(read_ratio, 3),
        "created": created,
        "read": read,
        "uncached": fresh,
    }

If read_ratio stays low even on later calls, it is either TTL expiry (a timing problem) or upstream volatility (an ordering problem). If it improves when you tighten the interval, blame the TTL. If it stays low regardless of interval, suspect the ordering.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Understand cascade invalidation — why changing one upstream block invalidates every cached block below it — alongside how to read cache_creation_input_tokens vs cache_read_input_tokens in usage
✦Reorder blocks from stable to volatile (tools → system → large constants → dynamic reference → conversation) and take home a decision table for where to spend your four breakpoints
✦Drop in a minimal guard that flags a hit-rate regression (cache_read ratio threshold) so an unattended pipeline notices when an innocent edit breaks caching
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⬡ API & SDK2026-09-07
A 75% cheaper cache read moved one bill by 29% and another by 2.8%
Fable 5.1 and Mythos 5.1 changed the cache read multiplier from 0.1 to 0.025. Here is how to estimate your own saving from your token mix, and how to fix code that hard-codes the multiplier.
⬡ API & SDK2026-04-26
How I Cut My Claude API Bill in Half With Prompt Caching
Done right, Anthropic's prompt caching can roughly halve your monthly API spend on workloads with long, repeated system prompts. Here is the design playbook I use after six months in production, including the arithmetic that links hit rate to the bill and the break-even points (about 22% on the 5-minute TTL, 53% on the 1-hour TTL).
⬡ API & SDK2026-05-25
A Two-Tier Setup — Haiku 4.5 Orchestrator with Opus 4.6 Worker for Balancing Cost and Quality
An indie developer's two-tier setup — Haiku 4.5 as orchestrator, Opus 4.6 as worker — costed line by line against published rates, plus the price increase I planned around that never arrived and the tokenizer split that quietly moves every token-denominated threshold.