Top-level cache_control
- What it does
- Automatic caching. The breakpoint moves to the last cacheable block as the conversation grows.
Prompt caching lets an LLM API reuse a processed prompt prefix. How Claude's cache_control and OpenAI's automatic caching work, TTLs, minimums and what breaks a hit.
Prompt caching lets a model API reuse the processed beginning of a prompt across requests instead of processing it again. Anthropic caches the prefix in the order tools, system, messages, up to a cache_control breakpoint. OpenAI caches by default when requests share an identical prompt prefix. Either way, a match needs the prefix to be identical.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
cache_controlcache_control on a block"ttl": "1h"system blockresponse.usageresponse = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
cache_control={"type": "ephemeral"},
system=[
{"type": "text", "text": "You are an AI assistant tasked with analyzing legal documents."},
{
"type": "text",
"text": "<full 50-page agreement text>",
"cache_control": {"type": "ephemeral", "ttl": "1h"},
},
],
messages=[{"role": "user", "content": "What are the key terms in this agreement?"}],
)
print(response.usage.model_dump_json())ttlAnthropic adds that caching does not change generated output. For what fills a request in the first place, see context window.
cache_controlcache_read_input_tokens and cache_creation_input_tokens in usageusage.input_tokens_details.cached_tokenstool_choice or add or remove imagesbudget_tokensKeep JSON key order stable in tool_use blocks, since Anthropic notes some languages randomize it. See also extended thinking for why changing a budget midway costs you the cache.
Within the lifetime. The first response should show tokens in cache_creation_input_tokens, the second in cache_read_input_tokens.
Anthropic gives the formula: cache_read_input_tokens plus cache_creation_input_tokens plus input_tokens.
The prompt was not cached, usually because it was under the model's minimum length.
Check usage.input_tokens_details.cached_tokens on the second call.
1 questions people ask next, answered from the sources on this page.
No. Anthropic states that caching does not change the generated output. It changes how much of the prompt is processed again and how that is billed.
The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.