Skip to navigation

Claude Code Cache Minimums: Why Short Prompts Cannot Be Cached

In short: Prompt caching has model-specific minimum sizes. A short system prompt may not qualify no matter how often you repeat it.

Published 19 min read
On this page

Direct answer

A short prompt can repeat perfectly and still miss the cache. Official: Claude prompt caching has model-specific minimum prefix sizes, and a cache hit requires identical prompt segments. If the reusable segment falls below the selected model’s minimum, repetition alone does not make it eligible.

The practical fix is not padding. Put genuinely stable, useful instructions and repository context into a consistent prefix, keep changing requests after it, then inspect cache-read and cache-write evidence from the route you actually use. A long prefix helps only when its content stays identical and earns its place.

Why a repeated short prompt still misses

Caching solves a narrow problem. A model service can reuse work for a prompt segment only when that segment meets the cache rules for the selected model. Frequency is not a substitute for size. Sending the same small instruction ten times does not change the length of the reusable segment.

The distinction matters when a team inspects a subscription bill or a gateway usage log. A short system message may look like an obvious cache candidate because it appears at the start of every request. Yet the documented minimum can be larger than the entire stable prefix. The request may be valid, useful and repeated while still producing no qualifying cache read.

Official: the supplied caching documentation lists several minimum sizes rather than one universal threshold. It also requires identical prompt segments for hits. Both conditions belong in the diagnosis. A prefix can clear the size threshold and still miss because a date, filename, timestamp or instruction changed inside it.

Claude Code adds another layer of uncertainty for readers comparing surfaces. The frozen evidence describes the model API’s caching rules, not a guarantee that every Claude Code screen exposes the same counters or bills subscription usage as a token API. Cache eligibility is a request-design question first. Verify the Claude Code billing effect on the actual route.

The Claude Code compaction context-retention test is relevant when a summary replaces earlier context. A compacted prefix may become shorter even though the session remains useful. Before blaming a missing cache read, check whether the stable text was summarized, reordered or regenerated.

Session continuity creates a similar measurement problem. The Claude Code session handoff and team context guide explains why a portable brief should carry decisions rather than a raw transcript. A handoff can improve the next request without making the prefix cacheable. Those are separate outcomes.

Cache evidence map showing a short prefix below the model minimum, a stable eligible prefix and the separate cache-read result.
Source: Official Claude prompt-caching documentation checked 2026-11-27. The map separates minimum-size eligibility from an observed cache read; it does not establish Claude Code subscription savings.

Official minimums are model-specific

Start with the model, not with a remembered number. Official: the documented minimum is 512 tokens for current Fable and Mythos 5.x models, Opus 5.5 and Opus 5, Sonnet 5.5 and Haiku 5.5. Several older models use a 1,024-token minimum. Mythos Preview and Opus 4.7 use 2,048 tokens. Opus 4.6, Opus 4.5 and Haiku 4.5 use 4,096 tokens.

Model group in the frozen evidence Minimum cacheable prefix What to check before reuse
Current Fable and Mythos 5.x 512 tokens Confirm the exact selected model and stable segment
Opus 5.5 and Opus 5 512 tokens Keep the reusable instructions identical
Sonnet 5.5 and Haiku 5.5 512 tokens Measure the prefix, not the whole conversation
Several older models 1,024 tokens Check the model’s own current documentation
Mythos Preview and Opus 4.7 2,048 tokens Do not borrow the current-family threshold
Opus 4.6, Opus 4.5 and Haiku 4.5 4,096 tokens A modest project brief may remain below the floor

The phrase “several older models” is deliberately incomplete because the frozen fact pack does not enumerate every ID in that group. Do not turn the row into a model allowlist. The current model catalogue and availability can help identify the route, while the official model documentation remains the authority for cache behavior.

A token is a model-processing unit, not a word. English prose, code, JSON and identifiers do not convert at one fixed ratio. A 300-word instruction file is not proof of a 512-token prefix. Use the token count reported by the API or the client’s own usage view when it is available.

The minimum is a floor, not a target. A 4,200-token prefix on a model with a 4,096-token minimum technically clears the documented size condition. It can still be a poor design if most of those tokens are stale boilerplate that no request needs.

Model changes also reset the question. The Claude Code custom API base URL guide explains why the selected endpoint and credential source must be known before interpreting a request. A trace from one model family should not be used to declare another family cacheable.

Design a prefix that is stable and useful

A useful prefix contains material that many requests need in the same form. Examples include durable repository conventions, a stable tool contract, a shared security boundary or a concise description of a subsystem. Length alone is not the test. Ask whether changing the text would damage several later requests.

Put volatile material after the stable section. A current branch name, failing test output, user-specific request or freshly read file usually belongs later in the prompt. If those details sit near the front and change between calls, they can break the identical segment required for a hit.

Prefix layer Good candidate Poor candidate Reason
Durable instructions Repository-wide conventions A new instruction for every task Shared rules survive many requests
Stable tool contract Unchanged schema and safety limits Rotating credentials or timestamps Secrets and volatile values do not belong in shared text
Subsystem context Concise architecture that stays true An entire frequently edited document Smaller stable context is easier to maintain
Task input A fixed reference used across a test set Live logs and branch names Volatility belongs after the reusable prefix

Scope discipline supports cache design. The Claude Code overengineering and diff scope guide recommends a bounded change surface. That habit applies to prompts: include the context that changes the next decision, not every file the agent could discover.

Repository instructions deserve special care. The Claude Code repository prompt injection article explains why cloned project files are untrusted input. Do not promote a large instruction file into a privileged cache prefix merely to reach a threshold. Stable does not mean trustworthy, and cached does not mean approved.

Dependency instructions are another poor source of filler. The Claude Code dependency-install side effects guide treats installation as executable work. A package manifest can be relevant context, but copying it into every prompt to increase size adds noise without establishing safety.

A practical prefix review asks three questions. Does this material serve multiple requests? Is it likely to remain byte-for-byte stable? Can a reviewer explain why it belongs? If any answer is no, move the material later or remove it.

Cache workflow moving from a short prefix through model-specific minimum checks, stable-prefix assembly and observed cache reads.
Source: Derived workflow from official Claude caching rules checked 2026-11-27. The final cache-read step requires response evidence; the diagram does not promise a hit.

Padding creates a different problem

Padding means adding text that has no task value so a prefix crosses a minimum. It can make a numeric check pass while making the request worse. The model must process the extra input, the reviewer has more noise to inspect and the apparently stable text may become one more thing to maintain.

Suppose a model requires 512 tokens and the useful stable prefix contains 420. Derived: the shortfall is 512 - 420 = 92 tokens. That arithmetic proves only that the prefix is below the documented floor. It does not prove that adding 92 tokens of filler will produce a hit, lower cost or improve the answer.

A worse example uses an older model with a 4,096-token minimum. Derived: a 700-token useful prefix is 4,096 - 700 = 3,396 tokens below the floor. Padding that gap would more than quadruple the useful prefix before adding the changing request. 700 + 3,396 = 4,096, and 4,096 / 700 is about 5.85 times the original useful size.

Prefix case Arithmetic Eligibility conclusion Design conclusion
420 useful tokens, 512 minimum 512 - 420 = 92 short Below the documented floor Improve useful stable context or accept no cache
700 useful tokens, 512 minimum 700 - 512 = 188 above Clears size only Still requires identical segments and observed reads
700 useful tokens, 4,096 minimum 4,096 - 700 = 3,396 short Below the documented floor Do not add 3,396 tokens of filler
4,200 tokens with 200 stale tokens 4,200 - 200 = 4,000 useful Depends on the model Remove stale text even if the total clears a floor

These examples are Derived from the official minimums and stated assumptions. They are not measured cache-hit rates, prices or productivity results. No token price is assumed because the frozen evidence does not supply a universal cache discount that can be applied to Claude Code subscriptions.

A long conversation is not automatically a long stable prefix. Tool output, error traces and intermediate edits may change on every turn. They can increase total input while leaving the reusable segment small. Measure the segment that is supposed to repeat, not the largest request in the session.

The Claude Code thinking tokens and output caps article covers a different token category. Reasoning and final output should not be confused with cacheable input. Adding output allowance does not increase a prompt prefix’s eligibility.

Cache tradeoff comparison between a short useful prefix, an eligible stable prefix and a padded prefix that clears the minimum with stale text.
Source: Derived comparison using official model-specific cache minimums checked 2026-11-27. The visual shows eligibility arithmetic, not measured savings or a recommended padding strategy.

Measure cache behavior without inventing savings

Begin with a small, repeatable request set. Use the same model, the same useful stable prefix and a changing task input placed after it. Save the request shape, selected model, date and returned usage fields. A cache claim needs more than a faster-feeling session.

Look for cache-read and cache-write evidence where the route exposes it. A write indicates that cache material was created under the service’s rules. Cache reads indicate reuse. If neither appears, record that result rather than assuming the client hid a successful hit.

Unknown: the supplied sources do not establish which cache counters appear on every Claude Code subscription surface. The sources also do not provide a universal mapping from an API cache-read count to a subscriber’s quota charge. The Claude Code cost per verified change framework is useful here because it keeps an unverified token-saving claim out of the accepted-work calculation.

Measurement step Record Decision it supports
Fix the model Exact model ID and route Select the correct documented minimum
Count the stable segment Reported tokens for the intended prefix Determine whether size eligibility is plausible
Repeat a controlled request Same stable segment, changing task input Test identical-prefix behavior
Inspect usage Cache reads, cache writes and input totals Confirm observed caching rather than infer it
Compare accepted work Correctness, review time and rework Decide whether the design helped the workflow
Repeat after a model change New trace with the new model Avoid carrying an old threshold forward

Use the LLM cost calculator for rate arithmetic when you have verified rates. Do not use it to manufacture a Claude Code cache discount from a subscription price. The OpenAI versus Anthropic API format guide explains why usage fields and feature controls can differ between routes.

A safe test should avoid sensitive material. The Claude Code secrets in logs and transcripts guide describes why prompts and tool output can persist in local records. Use synthetic repository notes or approved documentation when checking prefix stability.

Record failures as carefully as successes. A changed model, edited instruction or reordered block can explain a miss. Without those details, the team may conclude that caching is broken when the request no longer matches the documented conditions.

Worked example: compare eligibility, not imagined discounts

Take two synthetic prefixes. Prefix A contains 400 tokens of useful stable instructions. For comparison, Prefix B contains 650 tokens of useful stable instructions. Both are followed by a changing task request. The selected model has a 512-token minimum.

Derived: Prefix A is below the floor by 512 - 400 = 112 tokens. Prefix B clears the size condition by 650 - 512 = 138 tokens. That is the full eligibility conclusion available from size alone. Prefix B still needs identical segments and an observed cache read.

Now repeat each request five times with the same stable prefix and a different task suffix. Derived: the gross stable-prefix traffic presented across the ten requests is (400 × 5) + (650 × 5) = 5,250 tokens. That number describes repeated input volume. It is not a bill and not a savings figure.

Should Prefix B record cache reads on later requests, the trace establishes reuse for those requests under that route’s rules. Without those reads, the size calculation did not prove caching. Check the model, exact segment identity and usage output before changing the design.

A third test moves one volatile line into Prefix B. At that point, the stable segment is no longer identical across requests. Move the line into the changing suffix rather than enlarging the prefix. This is why prefix ownership matters: someone must be responsible for changes that affect every request.

The Claude Code proof-of-work packet offers a useful standard for the result. A screenshot of a lower token count is not enough. Save the request structure, returned usage evidence and the accepted task outcome together.

Read the trace in order

A cache investigation becomes easier when the evidence follows the request lifecycle. First identify the route and model. Next inspect the stable segment as sent. Then compare later requests against that exact segment. Finish with the returned usage and the task result.

Start with identity. A model alias can hide a change in the underlying model, and a custom route can expose different fields. Record the exact ID shown by the route rather than relying on the name in a client tab. The current model catalogue and availability is a navigation aid, not a substitute for the response trace.

Next inspect ordering. Two requests can contain the same instructions in a different order and still fail the identical-segment requirement. Diff the serialized prefix if the result is surprising. Look for moved blocks, regenerated summaries, changed whitespace inside a marked segment or a volatile value inserted near the front.

Then inspect the counters. Separate input, cache-read and cache-write fields where the route provides them. Do not add them together blindly or compare counts from different formats without checking their definitions. The OpenAI versus Anthropic API format guide explains why field names and feature controls differ.

Finish with accepted work. One request that records a cache read but produces an incorrect patch is not a workflow win. Another request that misses the cache but solves a narrow task cleanly may still be the better design. The Claude Code cost per verified change method keeps that outcome visible.

Cache control checklist covering model selection, prefix token count, identical segments, usage evidence and accepted task outcomes.
Source: Derived measurement checklist from official caching rules checked 2026-11-27. The controls validate a local test; they do not establish a universal hit rate.

A cache checklist for real projects

Run this checklist before changing a production prompt. It is intentionally smaller than a caching framework.

  1. Identify the exact model and API route. Do not apply a current-family minimum to an older model.
  2. Define the stable prefix in writing. Name the blocks that must remain identical.
  3. Count that prefix with the route’s reported token usage. Do not estimate from word count.
  4. Move dates, branch names, fresh logs and task-specific requests after the stable segment.
  5. Remove stale text even when the total prefix already clears the minimum.
  6. Test with synthetic or approved content and save cache-read and cache-write fields.
  7. Compare correctness, review time and rework. A cache hit is not an accepted change.
  8. Repeat the test after a model change or a significant instruction edit.

The Claude Code settings-file secret exposure guide is a useful guardrail when cache experiments touch local configuration. Do not place credentials in a prefix, a fixture or a shared log. The Claude Code harness security boundaries article explains why prompt content and tool authority need separate controls.

A cacheable prefix can still carry excessive authority. Review it as configuration, not just text. The Claude Code plugin security audit guide applies the same principle to executable extensions: inspect what a component can change before trusting its presence.

Keep the experiment reversible. Save the original prefix and the exact change. If accepted-work quality falls, restore the previous design even when cache reads look better. The Claude Code rewind and checkpoint limits article notes that shell and external changes are not fully covered, so do not rely on rewind as the only version-control mechanism.

Cache verdict separating a short prompt that misses the minimum, a useful stable prefix that can qualify and padding that is rejected.
Source: Official Claude cache minimums plus derived design guidance checked 2026-11-27. The verdict rejects padding and does not promise savings on any Claude Code plan.

Honest loss and data gaps

The concrete win is a clear eligibility test. A team can identify the selected model, measure the intended prefix and reject a cache explanation when the segment is below the documented minimum. That replaces a vague complaint with a checkable condition.

The concrete loss is that eligibility does not prove value. Even an identical prefix above the minimum can fail to produce reads, and a successful cache read does not prove lower total workflow cost. Extra context can increase review time or steer the agent toward irrelevant material.

Unknown: the frozen evidence does not provide a Claude Code-wide cache-hit rate, a universal token-saving percentage or a subscription-billing conversion for cache reads. It also does not enumerate every older model in the 1,024-token group. Those gaps should remain visible until official documentation or a controlled local trace answers them.

Update this guidance when the official model list or minimums change. Keep the measurement method stable so older traces remain interpretable. A dated model ID and request shape are more useful than a remembered threshold.

Practical alternative: compare routes with the same task set

One AI API Key can support a controlled comparison in an OpenAI-format agent without implying that the free lane works inside Claude Code. On 2026-11-27, the 46 live free model IDs covered 22 families. They shared 100 requests and 5,000,000 tokens per day per account, resetting at 05:30 IST or 00:00 UTC. Accounts could have up to three keys, with one request in flight per key on free models.

Use an OpenAI-format agent such as OpenCode, Cline or Cursor with https://api.oneaiapikey.com/v1, one key and a selected free ID. Its endpoint quickstart shows the first request. Prepaid pricing explains billing, and new accounts received $10 credit without a card under the frozen evidence.

Do not put these free IDs into Claude Code. They are OpenAI-format only. Claude Code’s documented route uses the Anthropic Messages format, but all four Claude IDs were unavailable on 2026-11-27. The coding-agent API key compatibility guide keeps that boundary explicit.

For a cache experiment, another model family is not a drop-in control. Minimums, cache behavior and exposed usage fields can differ. Compare each route against its own documentation, then compare accepted work, review time and rework with the cost per verified change method. Use the per-key caps, expiry and model allowlists to limit the test, and review the gateway privacy and retention policy before sending repository content.

The honest loss is workflow portability. An OpenAI-format agent may not reproduce Claude Code’s tools, permissions or session behavior. A different token bill cannot prove a better result until the same acceptance rules are applied.

Choose the next diagnosis by failure mode

Session and access failures need different evidence from cache misses. The Claude Code offline-mode boundaries separate local files from cloud inference, while the Claude Code mobile Remote Control limits explain why phone approval is not full review. Platform and credential failures belong to the Claude Code Linux ARM and headless login and Claude Code macOS Keychain permissions guides.

When the prompt changes because the task expanded, use the Claude Code database migration safety and Claude Code gitignored-file deletion risks guides to bound side effects. The Claude Code MCP trust boundaries and Claude Code security-research refusal workflow address tool output and authorization rather than prefix size.

Network symptoms can mimic application failures. Separate checks appear in the Claude Code network storm and NAT retry diagnosis, Claude Code corporate proxy TLS and mTLS and Claude Code outage status and failover guides. For a platform-specific command failure, use the Claude Code PowerShell path quoting article.

For plan and reasoning choices, read the Claude Code annual plan lock-in analysis, Claude Code Max and Ultra tier value, Claude Code fast-mode speed and cost and Claude Code Batch API versus subscription. The Claude Code reasoning effort defaults guide covers depth, while the Claude Code code-review bottleneck measures accepted delivery.

Provenance and licensing remain separate from performance. The Claude Code AI attribution and provenance guide records how a change was reviewed. Dependency and copied-code risk belong to the Claude Code generated-code license compliance guide. Reported task boundaries appear in the Claude Code game-development IP restrictions article.

FAQ

Can a short prompt be cached if it is repeated many times?

Not merely because it repeats. The stable segment must meet the selected model’s documented minimum and remain identical. Verify actual cache reads in the response usage evidence.

What is the Claude Code prompt cache minimum?

There is no single minimum across all models. The frozen official evidence ranges from 512 tokens for listed current models to 4,096 tokens for Opus 4.6, Opus 4.5 and Haiku 4.5, with other documented groups between them.

Should I pad a short system prompt to reach the minimum?

No. Add only stable, useful context that serves later requests. Padding can increase noise and input while still failing to produce a cache read.

Does a cache read prove my Claude Code subscription got cheaper?

No. The supplied evidence does not map API cache counters to a universal Claude Code subscription charge. Measure accepted work and verify the billing route separately.

Can the 46 free gateway IDs be used in Claude Code?

No. They use the OpenAI format and require an OpenAI-format agent. The documented Claude Code route uses the Anthropic format, and all four Claude IDs were unavailable on 2026-11-27.

Sources

More in Blog

Try it

One API key for GPT, Grok, DeepSeek, Kimi, GLM, MiniMax, Qwen, Step, Beam, Nemotron, ERNIE, Hunyuan, Gemma, Laguna, LFM, LongCat, Llama, Solar, Jais, Mistral, K2 and Roleplay.

One AI API Key speaks the OpenAI and Anthropic formats, so you change the base URL and the key, not your code. Credit packs start at $10, and every model has a published per-token rate.

New accounts$10 credit on sign-up
  • 100requests
    per day
  • 3Mtokens
    per day
  • 47free
    models
  • $0per
    token
  • No card
  • No end date
Claim $10 credit →