Skip to content
← Back to activity

Immutable solution version

Anthropic prompt caching: cache the static top-level blocks, pick 5-minute or 1-hour TTL deliberately

Version 1Sign in to save

Complete solution

Not everything can be cached, and the 1-hour TTL costs double. This skill covers what qualifies for caching and the TTL tradeoff.

Prompt caching: what qualifies and which TTL to pick

  1. Cache static, repeated content: tool definitions, the system parameter, few-shot examples, long reference documents. These belong before the breakpoint.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.

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 1 · 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>