CertSafari
    Anthropic Claude Certified Developer – Foundations (CCDV-F)· Lessons

    Domain 5 · Lesson 15/25

    Prompt caching: breakpoints, TTLs and hit rates

    Cost and Token Management

    13 min read
    4.2% of exam
    3 sources
    Published 12 Oct 2026
    Docs as of 30 Sep 2026

    What you will be able to do

    • Explain how a prompt prefix becomes a cache hit and which changes invalidate it
    • Place cache_control breakpoints on stable content above the model's minimum cacheable length
    • Choose between the 5-minute and 1-hour TTL from write cost, read count and the gaps between requests
    • Measure cache hit rate from the usage fields and spot a broken cache

    1.How a prompt prefix becomes a cache hit

    Prompt caching lets a request reuse the processed prefix of an earlier, identical prompt, so you pay a fraction of the input price for that prefix. When caching is enabled, the API checks whether the prompt up to a cache breakpoint was cached by a recent request. If it was, the cached version is used. If not, the full prompt is processed and the prefix is cached once the response begins. The cache key is a cryptographic hash of the prompt up to the breakpoint, so only an identical prefix can hit.

    The simplest way to turn it on is automatic caching: a single top-level cache_control field. The system places the breakpoint on the last cacheable block and moves it forward as a conversation grows. Each turn then reads everything before the new turn from cache and writes only the new content.

    Automatic caching: one top-level cache_control fieldpython
    client = anthropic.Anthropic()
    
    response = client.messages.create(
        model="claude-opus-5-5",
        max_tokens=1024,
        cache_control={"type": "ephemeral"},
        system="You are an AI assistant tasked with analyzing literary works. Your goal is to provide insightful commentary on themes, characters, and writing style.",
        messages=[
            {
                "role": "user",
                "content": "Analyze the major themes in 'Pride and Prejudice'.",
            }
        ],
    )
    print(response.usage.model_dump_json())

    Because a hit needs an exact prefix, some changes outside the text also break it. The cache is layered: tools, then system, then messages. Editing a tool definition invalidates all three layers. Turning web search or citations on or off changes the system layer and everything after it. Changing tool_choice, adding or removing images, or changing thinking parameters or the effort setting invalidates at least the message layer. Prompt caching has needed no beta prefix for some time. Code that calls client.beta.prompt_caching is outdated and should use client.messages.create.

    Checkpoint 1 of 6· Check yourself

    An agent's tools, system prompt and conversation are all cached. Which single change forces every layer to be written again?

    Sources1

    2.Where to put cache_control breakpoints

    Put the breakpoint on the last block that stays the same from one request to the next. A cache write happens only at the block you mark, and every later request with the same prefix reads that entry. If you put the breakpoint on something that changes every time, such as a timestamp or the user's latest message, each request writes a new entry and never hits. For most prompts, one breakpoint at the end of the static content is enough.

    Use more than one breakpoint, up to four, when parts of the prompt change at different rates. A typical four-breakpoint agent caches the tool definitions, the static instructions, the RAG documents and the conversation separately. A change at one breakpoint invalidates that segment and the segments after it, but the earlier segments stay valid. A second reason for extra breakpoints is a long conversation that has moved 20 or more blocks past the last cache write, outside the lookback window. Breakpoints themselves cost nothing. You pay only for the tokens written and read.

    Four-breakpoint layout and what each change invalidates
    BreakpointCachesIf this changes, still reused
    1All tool definitionsNothing
    2Static system instructionsTools
    3RAG knowledge-base documentsTools and instructions
    4Conversation so farTools, instructions and documents
    Explicit breakpoint on the system prompt combined with automatic caching for the conversationjson
    {
      "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?" }]
    }

    A breakpoint also does nothing if the prefix before it is too short. Each model has a minimum cacheable length: 512 tokens for Fable 5.1, Mythos 5.1, Opus 5.5, Opus 5 and Sonnet 5.5; 1,024 for Opus 4.8 and Sonnet 5; 4,096 for Haiku 4.5. A shorter prefix is processed normally with no cache write and no error. The only sign is cache_creation_input_tokens staying at zero. The automatic-caching sample above has a system prompt of a few dozen tokens, well under any minimum.

    Checkpoint 2 of 6· Exam question

    A finance team wants a monthly cost model for an internal Claude-powered summarization service. They know the average input tokens per call, average output tokens per call, and call volume, but the engineering team also plans to introduce prompt caching for a shared instruction block. Which combination of usage fields should the cost model consume from the API responses to produce an accurate blended cost once caching is live?

    Checkpoint 3 of 6· Check yourself

    A Sonnet 5.5 service marks a 400-token system prompt with cache_control. The rest of the prompt varies per request. Every response shows cache_creation_input_tokens: 0. What is going on?

    Sources1

    3.Choosing the 5-minute or 1-hour TTL

    Cache writes cost more than plain input, and how much more depends on how long the entry lives. A 5-minute entry costs 1.25x the base input price to write. A 1-hour entry costs 2x. Reads cost 0.1x on most models, 0.05x on Opus 5.5 and 0.025x on Fable 5.1. Each time an entry is used, its lifetime is refreshed at no extra cost. So a 5-minute entry stays warm as long as requests keep arriving within five minutes of each other.

    Cache prices per million tokens on current models
    ModelBase input5m write1h writeHit
    Claude Opus 5.5$4$5$8$0.20
    Claude Sonnet 5.5$2$2.50$4$0.20
    Claude Haiku 4.5$1$1.25$2$0.10

    The lifetime starts when the request begins, not when its response ends, so long generations shorten the window for reuse. The TTL choice then comes down to the gaps between requests, because a miss on either duration bills the whole prefix at the write price again.

    The break-even points follow from the table. Take a 1M-token prefix on Sonnet 5.5, where a request without caching pays $2 for the prefix. With the 5-minute TTL, a write plus one read costs $2.50 + $0.20 = $2.70, against $4.00 for two uncached requests, so one read already pays for the write. With the 1-hour TTL, a write plus one read costs $4.00 + $0.20 = $4.20, still above $4.00; a second read brings it to $4.40 against $6.00 uncached. Two reads is the break-even for the 1-hour entry. These counts assume the standard 0.1x read price; Opus 5.5 and Fable 5.1 read for less, so they pay off sooner.

    When turns arrive seconds apart, the 5-minute entry never expires, so the 1-hour entry's extra write cost (2x instead of 1.25x) buys nothing. In Anthropic's measurements of agent runs with no pauses, the 5-minute setting cost 15% less than the 1-hour one on Sonnet 5 and about 15% to 18% less on Opus 5.5. That figure is a whole-task cost, so it is smaller than the gap on the prefix alone. The 1-hour entry wins once pauses start to cause misses: a gap between 5 minutes and an hour expires the 5-minute entry and rebills the prefix at 1.25x, where the 1-hour entry would have read it at 0.1x. Anthropic's rule of thumb is to switch to the 1-hour TTL when more than about 1 gap in 20 falls in that range, and it is a measured threshold rather than a derived one. Gaps longer than an hour expire either kind of entry.

    Batches need extra care with caching. Batch requests run concurrently and in no fixed order, so cache hits are best-effort, and many batches take between 5 minutes and an hour to finish. To warm the cache deliberately, use the 1-hour TTL in this order:

    Checkpoint 4 of 6· Put it in order

    Put the steps for warming a 1-hour cache for a batch in order

    1. 1.Gather the message requests that share a prefix
    2. 2.Submit the rest of the requests
    3. 3.Monitor the job until that request completes
    4. 4.Send a batch containing a single request with that prefix and a 1-hour cache block

    Checkpoint 5 of 6· Exam question

    A latency-sensitive voice assistant relies on a large cached system prompt to keep response times low. Product wants to guarantee the cache is always warm the instant a user starts speaking, even after periods with no traffic, without waiting for an actual user request to trigger the cache write. Which technique addresses this directly?

    Sources231

    4.Measuring cache hit rate

    Your hit rate is the share of input tokens served from cache: cache_read_input_tokens divided by total input. On the first request of a cached agent, almost all input appears in cache_creation_input_tokens and reads are zero. On later turns, reads cover everything already cached, and creation covers only the newest turn. Organization-wide, the Usage API reports the same split, and the Console plots cache rate hour by hour.

    Caching makes the biggest difference in agent loops. Every turn resends the system prompt, the tools and all previous turns, so cost grows roughly with the square of the number of turns. In Anthropic's measurements, caching cut agent-loop cost by a factor of 2.7 to 5.3. Over a day of real traffic, agent loops read a median 84% of their input from cache, and the top tenth read 94% or more. A rate below about 80% usually means something is breaking the cache. Common causes are a timestamp ahead of the breakpoint, tool definitions that change between turns, or gaps longer than the TTL.

    Checkpoint 6 of 6· Check yourself

    An agent loop with turns a few seconds apart reads only 35% of its input from cache. The system prompt starts with the current time. What is the most likely fix?

    Sources21

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 1.Each extra cache_control breakpoint adds to the bill, so you should use as few as possible.Why is that wrong?

      Breakpoints are free. Cost depends only on how many tokens are written to and read from cache.

      Covered in Where to put cache_control breakpoints

    2. 2.The cache TTL starts counting when the response finishes streaming.Why is that wrong?

      The lifetime starts when the request that writes or reads the entry begins, so generation time uses up part of the window.

      Covered in Choosing the 5-minute or 1-hour TTL

    3. 3.The 1-hour TTL is always the cheaper choice because entries last longer.Why is that wrong?

      A 1-hour write costs 2x the input price versus 1.25x and needs two reads to pay off, so for turns seconds apart the 5-minute default is cheaper.

      Covered in Choosing the 5-minute or 1-hour TTL

    Practise it for real

    Watch a prompt prefix go from cache write to cache hit to cache miss in the usage fields

    1. 1.Take the automatic-caching sample (top-level cache_control with type ephemeral) and lengthen its system prompt to well over 512 tokens, then send it to claude-opus-5-5

      Why: Opus 5.5 won't cache a prefix under 512 tokens, and the sample's short system prompt is under that

      You should see: usage shows cache_creation_input_tokens above zero and cache_read_input_tokens of 0

    2. 2.Send the identical request again within five minutes

      Why: An identical prefix within the TTL should be read from cache instead of written

      You should see: cache_read_input_tokens now covers the prefix, and input_tokens is small

    3. 3.Change one word near the start of the system prompt and send it again

      Why: The cache key is a hash of the prefix, so any edit makes it a new prefix

      You should see: cache_read_input_tokens drops to 0 and cache_creation_input_tokens rises again

    Stuck? Get a nudge

    If cache_creation_input_tokens stays at 0 on the first call, count the system prompt with count_tokens. It is probably still under the minimum.

    Sources

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Otherwise, it processes the full prompt and caches the prefix once the response begins.”
      ↩︎ How a prompt prefix becomes a cache hit
      “This means only requests with identical prompts can access a specific cache.”
      ↩︎ How a prompt prefix becomes a cache hit
      “Changes at any breakpoint invalidate that segment and everything after it, while earlier cached segments remain valid”
      ↩︎ Where to put cache_control breakpoints
      “4,096 tokens for Claude Haiku 4.5”
      ↩︎ Where to put cache_control breakpoints
      “512 tokens for Claude Fable 5.1, Claude Mythos 5.1, Claude Opus 5.5”
      ↩︎ Where to put cache_control breakpoints
      “because asynchronous batch requests can be processed concurrently and in any order, cache hits are provided on a best-effort basis.”
      ↩︎ Choosing the 5-minute or 1-hour TTL
      “You can monitor cache performance using the cache_creation_input_tokens and cache_read_input_tokens fields in the API response.”
      ↩︎ Measuring cache hit rate
      “The number of breakpoints doesn't affect pricing; only the amount of content cached and read matters.”
      ↩︎ Exam trap 1
      “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 2
      “Modifying tool definitions (names, descriptions, parameters) invalidates the entire cache”
      ↩︎ Checkpoint
      “Shorter prompts cannot be cached, even if marked with cache_control.”
      ↩︎ Checkpoint
      “a follow-up request that reuses the same cached prefix must start within about 1 minute of that response completing”
      ↩︎ Prediction
      “Send a batch request with a single request that has this shared prefix and a 1-hour cache block.”
      ↩︎ Checkpoint
      “writes a fresh entry each time and never hits”
      ↩︎ Checkpoint
    2. 2.
      “A miss on either duration bills the whole prefix at the write price instead of the read price”
      ↩︎ Choosing the 5-minute or 1-hour TTL
      “More than about 1 gap in 20 falls between 5 minutes and an hour”
      ↩︎ Choosing the 5-minute or 1-hour TTL
      “it cost 15% less than the 1-hour setting on Claude Sonnet 5”
      ↩︎ Choosing the 5-minute or 1-hour TTL
      “agent loops read a median 84% of their input from the cache”
      ↩︎ Measuring cache hit rate
      “Below about 80%, look for something breaking the cache”
      ↩︎ Measuring cache hit rate
    3. 3.
      “caching pays off after one cache read for the 5-minute duration (1.25x write), or after two cache reads for the 1-hour duration (2x write)”
      ↩︎ Choosing the 5-minute or 1-hour TTL
      “caching pays off after one cache read for the 5-minute duration (1.25x write), or after two cache reads for the 1-hour duration (2x write)”
      ↩︎ Exam trap 3

    Ready to test yourself?

    Practise the 20 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.