HomeLearnCoursesHackathonsAccount
Mastering the Claude API
Prompt Caching for Cost and Latency · 1/2

What caching actually does

Every request you send re-transmits and re-processes the full conversation history, including any large, unchanging content like a system prompt, a tool catalog, or a reference document — Claude has no persistent memory, so that cost repeats on every call. Prompt caching lets you mark a point in the request with cache_control so that Anthropic's infrastructure stores everything up to that point and, on a subsequent request with an identical prefix, skips reprocessing it. Cached input tokens are billed at a fraction of the normal input rate, and time-to-first-token drops noticeably, which is the latency win developers usually notice first.

Caching is a prefix match, and that's the detail that trips people up: everything before your cache_control breakpoint has to be byte-for-byte identical to the previous request, or the cache misses entirely — not partially, but for the whole cached region. Request rendering order is tools, then system, then messages, so stable content belongs first (a frozen system prompt, a deterministic tool list) and volatile content (a timestamp, a per-request user question) belongs after the last breakpoint, never before it.