← Blog

Best Practices for Claude API Prompt Caching

2026-11-07 · 5 min read · SubToAPI Team

Prompt caching lets Claude reuse previously processed portions of a prompt instead of re-running the full context through the model on every request. If you're sending the same system prompt, the same set of documents, or the same tool definitions on repeated calls, caching can cut both latency and token cost significantly — often by 80-90% on the cached portion. The best practices below cover where to place cache breakpoints, how to structure prompts so they actually hit the cache, and what mistakes silently break caching.

The short answer: put static, reusable content at the top of your prompt, mark it with a cache control breakpoint, keep that content byte-for-byte identical between calls, and only append the variable parts (user messages, fresh data) after the cached block. Everything else in this guide is detail around that core rule.

How Claude's prompt cache actually works

Claude caches prefixes of your prompt, not arbitrary chunks. When you mark a block with a cache breakpoint, Claude stores the processed state of everything up to and including that point. On a subsequent request, if the prefix matches exactly, Claude skips re-processing it and reads from cache instead.

This has two direct implications:

Cache entries typically have a short time-to-live (on the order of minutes), so caching is most effective for prompts reused in a burst: a chat session, a batch of document-analysis calls, or a high-traffic endpoint where multiple requests share the same system prompt within a short window.

Structuring prompts for maximum cache hits

1. Isolate the stable layer. Separate your prompt into three logical layers: a stable layer (system instructions, style guides, tool definitions), a semi-stable layer (a document or dataset relevant to the current session), and a volatile layer (the user's latest message). Cache breakpoints go at the boundary between stable/semi-stable content and volatile content.

2. Put large reference material early. If you're doing retrieval-augmented generation or long-document analysis, load the document once, cache it, and then send different questions against it. This is the highest-value caching pattern because document tokens are usually the bulk of the prompt.

{
  "system": [
    {
      "type": "text",
      "text": "You are a contract analysis assistant. Full policy text: ... (10,000 tokens) ...",
      "cache_control": { "type": "ephemeral" }
    }
  ],
  "messages": [
    { "role": "user", "content": "Summarize section 4." }
  ]
}

3. Cache tool definitions separately from instructions if they change at different rates. If your tool schema is stable but your system prompt changes per customer (e.g., multi-tenant SaaS), put a breakpoint after the tool definitions and another after the tenant-specific instructions, so a change in one doesn't invalidate the other.

4. Don't cache content that changes every call. Timestamps, request IDs, or "current time: ..." strings inserted before the cache breakpoint will break caching for everyone. Move anything per-request to after the last breakpoint.

5. Keep cached blocks above the minimum token threshold. Very short cached segments aren't worth the overhead and may not be cached at all — caching pays off on prompts with a few thousand tokens or more of stable content.

Common mistakes that silently disable caching

Measuring whether caching is working

Track cache read and write token counts from the response usage metadata on every call. A healthy caching setup shows a high ratio of cache-read tokens to cache-write tokens over time — you want to write the cache once and read from it many times. If you're seeing roughly 1:1 writes to reads, something upstream is invalidating your cache between calls (check for the non-determinism issues above).

If you're running Claude behind an internal API for your product, this is also where SubToAPI is useful: it exposes your Claude access as a standard HTTPS endpoint with per-key usage metadata, so you can see cache read/write token breakdowns per application key without building your own logging layer. See the docs and messages reference for how usage fields are reported, or check pricing if you're evaluating it for a team.

A practical checklist

Prompt caching is one of the few optimizations that reduces both cost and latency simultaneously, but it only works if the prefix is genuinely stable across calls. Most caching failures come down to small, invisible differences in the "static" part of the prompt — fix those first before assuming caching doesn't help your use case.

questions

Does reordering my system prompt break an existing cache? Yes. Caching matches on the exact prefix, so any reordering, added whitespace, or wording change invalidates the cached segment and forces a full re-process on the next call.

How long does a Claude prompt cache entry last? Cache entries have a short TTL, typically a few minutes, and are refreshed on reuse. They work best for bursty or concurrent traffic against the same prefix, not for prompts reused once a day.

Can I cache tool definitions and documents independently? Yes, you can set multiple cache breakpoints at different points in the prompt, so a change in a document doesn't force re-caching of your tool schema, and vice versa.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →