Solution skill
Anthropic prompt caching: cache the static top-level blocks, pick 5-minute or 1-hour TTL deliberately
Complete solution
Shows how to fix anthropic prompt caching: cache the static top-level blocks, pick 5-minute or 1-hour TTL deliberately. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Use it for conversational or bursty workloads where the same prefix repeats within minutes. Use it only for prefixes reused across a long session (long documents, persistent system instructions) where the 5-minute window keeps expiring.
Steps
- Cache static, repeated content: tool definitions, the system parameter, few-shot examples, long reference documents. These belong before the breakpoint.
- Do not try to cache the varying tail: the current user message, per-request data, anything with a timestamp. Only the stable prefix is eligible.
- Cache the top-level block, not nested content. Anthropic's docs give citations as the example: citation content blocks themselves cannot be cached directly; cache the top-level document blocks that serve as the citation source material instead.
- Default TTL is 5 minutes, refreshed at no cost on every use. Use it for conversational or bursty workloads where the same prefix repeats within minutes.
- The 1-hour TTL (
{"cache_control": {"type": "ephemeral", "ttl": "1h"}}) is priced at 2x the base input token price. Use it only for prefixes reused across a long session (long documents, persistent system instructions) where the 5-minute window keeps expiring. - Combining explicit breakpoints with automatic caching is supported: the automatic behavior handles the rest while your explicit breakpoints pin the sections you care about.
- Failure modes this prevents: paying 2x for a 1-hour TTL on a prefix used twice; trying to cache nested citation blocks and getting no hits; caching per-request data that invalidates the prefix every call.
When to use
You are seeing this: Cache static, repeated content: tool definitions, the system parameter, few-shot examples, long reference documents. Use this skill when you run into "Anthropic prompt caching: cache the static top-level blocks, pick 5-minute or 1-hour TTL deliberately".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Anthropic's prompt-caching docs describe caching top-level blocks, the 5-minute default refreshed on use, the 1h TTL at 2x base input token price, and compatibility of automatic caching with explicit breakpoints. Verified live at https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching.
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_TCBrAEG79y_IUh7J184VGA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Anthropic prompt caching: cache the static top-level blocks, pick 5-minute or 1-hour TTL deliberately <span>— Vectle</span></a>