Skip to content
Claude Certified Architect – Professional (CCAR-P) Exam Prep

Lesson 8 of 31 · 7 min

x
8/31

Prompt Caching

Video lesson: CCAR-P 08/31: Prompt Caching

Everything below is verified against the prompt caching docs unless marked.

How it works

  • Prompt caching lets requests resume from a cached prefix, cutting time and cost for repeated context.
  • Two ways to enable it: automatic caching (one top-level cache_control; the system places the breakpoint on the last cacheable block) or explicit breakpoints on specific content blocks.
  • The cached prefix follows the order tools, then system, then messages, up to and including the block marked with cache_control.
  • Default lifetime is 5 minutes, refreshed on use; a 1-hour duration is available at additional cost. A response that takes 4 minutes to stream leaves about 1 minute for a follow-up to reuse the prefix.

Minimum cacheable length

On the Claude API (and AWS, Google Cloud and Foundry platforms): 512 tokens for Fable 5.1, Mythos 5.1, Opus 5.5, Opus 5, Sonnet 5.5, Fable 5, Mythos 5 and Haiku 5.5; 1,024 for Sonnet 5, Sonnet 4.6 and Opus 4.8 (and others); 2,048 for Opus 4.7; 4,096 for Opus 4.6 and 4.5. Shorter prompts are processed without caching and with no error; check usage fields to confirm.

Reading the usage fields

FieldMeaning
cache_creation_input_tokensTokens written to the cache this request
cache_read_input_tokensTokens read from the cache
input_tokensOnly tokens after the last breakpoint (not all input)

total input = cache_read + cache_creation + input_tokens. If both cache fields are 0, nothing was cached (often below the minimum length). Cached prefixes still count toward the context window; caching changes price, not size.

What invalidates the cache

Changes at one level invalidate that level and everything after it: tools, then system, then messages. Modifying tool definitions invalidates all three. Per other documented behaviour: changing tool_choice invalidates cached message blocks (tools and system stay), changing output_config.format invalidates the conversation's prompt cache, and clearing content with context editing rewrites the prefix (use clear_at_least so it pays).

Design rules (design guidance)

  1. Put stable content first (tool definitions, system prompt, reference documents), volatile content last (the user turn).
  2. Keep the tool set stable per session; do not reorder or edit tool definitions mid-conversation.
  3. Match cache duration to request gaps: if a person waits several minutes between turns, 5 minutes may expire; consider the 1-hour option.
  4. Batch plus caching: batch hits are best-effort because requests run concurrently in any order; use the 1-hour duration for shared context.
  5. Monitor cache hit rate as an operational metric (D3.4).

Anthropic's cost guidance reports prompt caching as usually the largest single cost lever in its measurements.

Exam traps

  • Dynamic text (timestamps, ids) at the top of the prompt, breaking the prefix every request.
  • Expecting a cache hit under the minimum length.
  • Reading input_tokens as total input.
  • Editing tool definitions per request.
  • Assuming caching shrinks the context window.

References

  1. Prompt caching — checked Oct 16, 2026
  2. Context editing — checked Oct 16, 2026
  3. Optimizing for cost and intelligence — checked Oct 16, 2026

Check your understanding

  • Total input in a cached request?Show answer

    Answer

    cache_read_input_tokens + cache_creation_input_tokens + input_tokens.
  • Both cache fields are 0. Likely cause?Show answer

    Answer

    Prompt below the minimum cacheable length (no error is raised).
  • Where should a per-request timestamp go?Show answer

    Answer

    At the end, after the cached prefix.
Previous

Progress is saved in this browser.

Next Lesson