What prompt caching does
Mark a prefix of your prompt as cacheable and Anthropic stores the model state for it. Subsequent calls that send the same prefix read from cache instead of re-tokenizing — significantly cheaper and faster. Cache reads typically cost a fraction of base input tokens; cache writes cost more than base input tokens (the first call), so caching pays off when the prefix is reused.
Where to put cache_control
You attach cache_control: {"type": "ephemeral"} to a content block (system text, tools list, message content, or document). The cache breakpoint marks 'everything up to here is cacheable.' Anthropic supports up to 4 cache breakpoints per request — enough for system + tools + a stable history slice.
What invalidates the cache
Any change to the cached prefix invalidates the cache. That includes whitespace changes in the system prompt, tool definition changes, or shuffled message order. Stable prefixes are the engineering goal; if your prompt construction reorders or rewrites things, you will rarely see a cache hit.