Anthropic CCA-F: Prompt Caching and Reusable Context
Prompt caching is an architecture technique for reusing stable prompt prefixes so repeated Claude requests can reduce cost and latency. The design challenge is deciding what is genuinely reusable, how long it should be cached, what invalidates it, how sensitive information is handled, and whether the cached prefix still represents the current instructions, tools, and business state. Caching a large prefix is valuable only when the content stays relevant, the authorized audience is unchanged, and repeated requests actually reuse it. A high cache-hit rate can conceal stale instructions or unnecessary context unless release tests cover those risks.
On this page
- Design the reusable prefix first
- Start with automatic caching
- Choose five-minute or one-hour duration deliberately
- Measure cache-read tokens
- Understand invalidation
- Cache tools carefully
- Use caching with citations and retrieval
- Do not cache sensitive context blindly
- Optimize caching as part of the full task
Prompt caching reduces the cost and latency of repeatedly sending the same large prefix to Claude. Anthropic’s current API can cache content across the tools, system, and messages sections of a request. Teams can use automatic caching—currently recommended as the starting point for most use cases—or explicit cache controls when they need precise breakpoints.
The feature is most valuable when the application has stable system instructions, examples, tool schemas, documents, or conversation prefixes reused across multiple requests. Caching is not a substitute for context engineering: irrelevant content remains irrelevant even when it becomes cheaper to process. In production Claude applications, cached prefixes must be versioned and invalidated when the underlying instructions, source permissions, or tool definitions change.
Design the reusable prefix first
Prompt caching works best when instructions, tool definitions, and reusable reference content form a stable prefix before dynamic user input. Start with context engineering: decide which information belongs in every request and which details should be retrieved only when relevant. Model, prompt, and tool versions should be controlled because a timestamp, tenant-specific value, or reordered definition can change the prefix enough to prevent reuse. Cache design therefore begins with content selection and ordering, not with adding a cache flag to an oversized prompt. Prompt-caching choices in Claude Certified Architect – Foundations (CCAR-F) must keep shared prefixes stable without allowing tenant-specific or unauthorized context to leak across requests.
Conversation caching can be combined with compaction. Active turns can reuse a cached prefix for speed, then server-side compaction can reduce the working history when it grows too large. The application should monitor whether compaction changes the stable prefix and whether expected cache-hit rates recover afterward. Do not confuse model-side prompt caching with application response caching. Prompt caching reuses model input processing while Claude still generates a fresh answer. Response caching reuses a previous final result and therefore needs much stricter equivalence, freshness, and authorization rules.
Prompt caching is most successful when the application can explain its prefix. Stable instructions and tools should be there because they improve the task, not because they are easy to cache. Relevance first, reuse second.
Start with automatic caching
Automatic prompt caching is a practical starting point when a Claude application repeatedly uses the same instructions, tools, or conversation prefix. A top-level cache control lets the platform manage cache breakpoints as the conversation grows. Use explicit breakpoints when the application needs detailed control over which content is reusable or when several stable sections have different lifecycles.
Automatic caching can be especially useful for long conversations because the prefix naturally grows while recent turns remain dynamic. Explicit caching is more appropriate when the application wants to pin a large document, fixed policy block, or tool library at a known boundary. Applications should also decide what happens on a cache miss. The request should remain functionally correct and simply cost more or take longer. If behavior changes because cached and uncached paths assemble different context, the cache architecture has become part of business logic and needs stronger testing.
Choose five-minute or one-hour duration deliberately
Claude supports a default five-minute cache lifetime and an optional one-hour duration, so the right choice depends on how often a stable prefix is reused. Five-minute cache writes are priced at 1.25 times standard input and one-hour writes at twice standard input; cache reads cost less than processing the same input again. Estimate the expected requests during each time-to-live period before paying for a longer cache. The economics belong within Claude cost control, alongside quality, latency, and retry behavior—not in a standalone cache-hit metric.
For mature workloads, cache strategy should be reviewed when model pricing, minimum cacheable token thresholds, or feature support changes. A configuration that was economical for one model generation may no longer be optimal after a migration. Keep the policy evidence-based rather than treating caching as a permanent one-time optimization. Cache strategy should be different for interactive and batch workloads. Interactive sessions benefit from short-lived reuse across rapid turns, while a repeated offline job may justify the one-hour duration if the same large prefix is used throughout the batch window.
Measure cache-read tokens
A cache flag does not prove that a request reused stored context. Measure cache creation tokens, cache-read tokens, uncached input, and resulting latency in the API usage data, then compare these values across repeated requests. Segment the measurements by model, prompt version, workflow, and tenant: a release that changes tool definitions or inserts a dynamic identifier into the reusable prefix may destroy hit rates even though the application still appears to use caching. Evaluate saved cost and processing time per completed task rather than optimizing hit rate in isolation.
Cache economics should include write churn. A workflow that constantly writes new large prefixes but rarely reads them again can cost more than ordinary uncached input. Track cache creation as well as hits and review workflows whose write/read ratio remains poor. Cache metrics should be connected to cost per successful task. A high hit rate can look good while an unnecessary giant prefix still dominates every request. Compare the cached design with a smaller uncached prompt; sometimes removing irrelevant context saves more than caching it.
Keep one benchmark without caching as a quality control. The output should remain semantically correct whether or not the prefix comes from cache. Caching is a transport and economics optimization, not a reason to accept behavior that changes depending on reuse state. Prompt caching can be included in performance regression tests. Send the same representative request once to create the cache, then repeat within the intended TTL and verify both usage fields and latency. This catches accidental prefix changes that would otherwise surface only as a production cost increase.
Understand invalidation
Cache invalidation follows the identity of the reusable prefix. Changes to the model, system instructions, tool definitions, or structured-output configuration can prevent a prior prefix from matching, even when the user-facing task looks identical. Use versioned prompt management to keep cached content aligned with the behavior and tools in each release, and verify hit rates after every change. For large tool catalogs, deferred discovery can reduce unnecessary definition changes and keep the common prefix more stable.
Finally, treat cache policy as release configuration. TTL, breakpoints, automatic-versus-explicit mode, model, prompt version, and tool set should be documented with the application release. When usage or latency changes, operators can then see whether the cache strategy changed rather than assuming the model became slower or more expensive. Keep cache metrics tied to release versions so operators can identify when a prompt, tool, context, or model change reduced reuse and increased cost or latency.
Review caching after major platform updates because supported models, minimum cacheable lengths, pricing multipliers, and feature interactions can change enough to alter the optimal breakpoint or TTL strategy.
Cache tools carefully
Tool definitions are part of the cached prefix, so a constantly changing catalog can waste cache writes and increase the context sent to the model. Keep frequently used tools and their schemas stable, and defer long-tail definitions with tool search when they are not required for the current task. This is also a Claude tool-design decision: narrower, clearly described capabilities improve tool selection and reduce context overhead without weakening application-side authorization.
Caching can also interact with server tools and tool loops. Anthropic currently adds automatic cache breakpoints around server-tool results when prompt caching is already enabled, which can reduce reprocessing during multi-step server-side interactions. Application traces should preserve enough usage detail to explain these hidden optimization effects. Large tool libraries are a common hidden cache problem. Adding a tool definition can invalidate the cached tools prefix, and constantly changing generated schemas can create repeated cache writes. Keep common tools stable, use deferred loading or tool search for a long tail, and version tool catalogs intentionally rather than constructing an arbitrary list on every request.
Use caching with citations and retrieval
Repeated questions about the same approved documents may benefit from caching stable source blocks or search results, but reuse must not bypass authorization or freshness checks. A sound Claude retrieval system still filters evidence by the current user’s permissions and excludes superseded information before it enters the model context. Include corpus, document, or policy versions in the invalidation strategy so a changed record cannot continue to appear as authoritative simply because it was cached in an earlier interaction.
RAG workloads can cache stable source blocks when many questions are asked about the same document or dataset. The application must still invalidate that cache when the authoritative content, access policy, or source version changes. Cache keys should therefore include the content or policy version rather than relying only on a user query.
Do not cache sensitive context blindly
A cached prefix can contain confidential business records, account information, or personal data, so reuse must follow the same privacy and tenant-isolation requirements as the original request. Decide which types of information may be cached, their retention limits, and the API configuration required by organizational policy. Avoid mixing customer-specific content into a shared reusable prefix, even when doing so would improve hit rates. The savings from a cache are never a justification for crossing an access boundary or retaining sensitive evidence beyond its authorized lifecycle.
Security review should include cache sharing. Reuse across requests is useful only when the cached content is valid for the same authorization scope. Do not maximize hit ratio by placing customer-specific policy, confidential documents, or personalized state in a prefix reused across tenants. Performance never justifies collapsing a data boundary.
Optimize caching as part of the full task
Caching can reduce model input processing while the real bottleneck remains retrieval, tools, network, or output generation. Claude latency should be measured end to end. For production workloads, the durable caching process is stable prefix → appropriate TTL → usage measurement → versioned invalidation → privacy review → quality check. The best cache is the one that saves real repeated work without making context stale or less focused.