Domain 5 · Context Management & Reliability
Prompt caching
If every request re-sends the same big system prompt, tool list, or document, you pay full
price to process those tokens every single time. Prompt caching lets Claude remember a
prefix it already processed and reuse it at a fraction of the cost and latency. Toggle caching and
watch the bill — and the clock — drop.
cache_controlprefix reuse
cache write vs readlatency
stable prefix first
Explain like I'm 10
Imagine telling a long bedtime story every night, but you always start with the same boring 10-minute intro
before the new part. Wouldn't it be nice to
bookmark the intro so you skip straight to "…and then,
tonight's new adventure"? Prompt caching is that bookmark. Claude remembers the part that never changes and
only does fresh work on the new bit — faster, and way cheaper.
Compare the bill: cache off vs on
You're answering 20 questions about the same 50-page contract. Without caching, all those contract tokens
are reprocessed on every question. With caching, the first call writes the cache (a small premium),
and the next 19 read it cheaply. Move the slider:
The rules that make it work
- Put stable stuff first. The cache works on a prefix: system prompt → tools → big docs →
then the changing user turn. Anything before your
cache_control breakpoint must be
byte-identical across calls, or the cache misses.
- Write once, read many. The first call pays a small write premium (~125% of base);
subsequent reads are deeply discounted (~10% of base). The break-even is usually just 2+ reuses.
- Mind the TTL. Cache entries expire (default ~5 minutes, refreshed on use). High-frequency traffic
benefits most; rare calls may let it lapse.
- Don't cache the volatile part. Caching the changing user question gains nothing — only cache the
repeated prefix.
Exam trap: caching only helps when a large, identical prefix repeats and
comes first. Ordering volatile content before stable content (so the prefix changes each call) is the
classic mistake — every call misses. And caching tiny or one-off prompts wastes the write premium. Cache the
big, stable, reused head; keep the variable tail outside the breakpoint.
Takeaways: prompt caching reuses an already-processed prefix to cut cost
and latency. Order stable content first (system → tools → docs) and mark the breakpoint with
cache_control; the variable user turn goes last. First call writes (small premium), later
calls read cheaply — worth it from ~2 reuses, within the cache TTL.
Curated companion: Anthropic — Prompt caching.