Claude Prompt Cache Not Working? A Four-Request Usage Test
Reproduce four native Claude requests with a stable prefix and explicit breakpoint. Observe cache writes, one read and an unexpected changed-question miss.

If Claude prompt caching appears broken, inspect cache-write and cache-read usage, then compare the complete prefix and cache breakpoint. Keep an unexpected miss visible: a successful hit on one request does not establish that later requests share the same cache state.
Crazyrouter is the AI API gateway used in this four-request native Claude test: the first request wrote 7,225 cache tokens, and the identical repeat read 7,225. A changed final question then reported another write with zero reads, even though the tested system prefix was unchanged.
By Sophie M · Tested November 3, 2026
Claude prompt cache not working: check usage first#
The Claude prompt-cache documentation explains explicit breakpoints, prefix matching, supported models and cache lifetimes. These details are model- and interface-dependent. For this experiment we used an explicit cache_control block with type: ephemeral; we did not test one-hour retention or wait for expiration.
The relevant response fields are cache_creation_input_tokens, cache_read_input_tokens, input_tokens, and output_tokens. Keep them distinct. An HTTP 200 or a fast response does not tell you which input was reused.
What changed in the four-request sequence?#
On November 3, 2026, Python 3.10.2 sent four requests to host https://api.crazyrouter.com, endpoint /v1/messages, model claude-sonnet-4-6. A random run marker plus 450 synthetic records formed a 28,856-character system prefix. Each response had to end with end_turn and return CACHE-1461.
| Case | New cache writes | Cache reads | Ordinary input | Seconds |
|---|---|---|---|---|
| first | 7225 | 0 | 13 | 2.934 |
| repeat | 0 | 7225 | 13 | 2.378 |
| changed question | 7225 | 0 | 17 | 2.053 |
| changed prefix | 7230 | 0 | 13 | 2.337 |
Observed response IDs (successful responses only):
msg_011CgfqrbDjc6mE9yTCEdCu7
msg_011CgfqrmJxeWXkb2C8wmnGY
msg_011CgfqruEhMxuf9c9bzmdzw
msg_011Cgfqs6W7ugWPVk6ZWDD74

The first three requests had the same recorded SHA-256 system-prefix digest. The changed-question request nevertheless reported 7,225 newly written tokens and zero cache reads. We did not inspect upstream routing or internal normalization, so neither can be stated as the cause. The final case prepended “Revised records.” and reported a new 7,230-token write.
Run the complete native probe#
Install requests, set CRAZYROUTER_API_KEY in the process environment, save this as claude_cache_probe.py, and run it. It prints the usage counters, prefix digest, response ID and validated answer for each request. Each execution uses a new run marker.
"""Four native Messages requests with explicit prompt-cache controls."""
import hashlib
import json
import os
import time
import uuid
import requests
def main():
session=requests.Session();session.trust_env=False
session.headers.update({'Authorization':'Bearer '+os.environ['CRAZYROUTER_API_KEY'],'anthropic-version':'2023-06-01'})
endpoint='https://api.crazyrouter.com/v1/messages';model='claude-sonnet-4-6'
prefix='Synthetic cache fixture '+uuid.uuid4().hex+'\n'
prefix+='\n'.join(f'Record {i:04d}: synthetic item, approved status, no customer data.' for i in range(450))
rows=[]
cases=[('first',prefix,'Reply only CACHE-1461'),('repeat',prefix,'Reply only CACHE-1461'),('changed question',prefix,'Using the records, reply only CACHE-1461'),('changed prefix','Revised records.\n'+prefix,'Reply only CACHE-1461')]
for label,system,question in cases:
payload={'model':model,'max_tokens':32,'system':[{'type':'text','text':system,'cache_control':{'type':'ephemeral'}}],'messages':[{'role':'user','content':question}]}
start=time.perf_counter();response=session.post(endpoint,json=payload,timeout=90)
response.raise_for_status();data=response.json()
answer=''.join(x.get('text','') for x in data['content'] if x['type']=='text')
assert data['stop_reason']=='end_turn' and answer.strip()=='CACHE-1461'
rows.append({'label':label,'response_id':data['id'],'http':response.status_code,'seconds':round(time.perf_counter()-start,3),'output':answer,'usage':data.get('usage',{}),'prefix_sha256':hashlib.sha256(system.encode()).hexdigest(),'finished':True})
print(json.dumps({'endpoint':endpoint,'model':model,'prefix_chars':len(prefix),'requests':rows}))
if __name__=='__main__':main()
This is a diagnostic sequence, not an automated repair. It does not change routing, alter the TTL or retry a miss until it looks successful. The bounded retry guide covers transient request failures separately.
A diagnosis order that preserves evidence#
| Check | Evidence to retain | What it can establish |
|---|---|---|
| Correct native interface | Endpoint and request shape | Whether the cache directive was placed in the tested protocol |
| Complete response | Stop reason and expected output | Whether the generation completed |
| Prefix identity | Serialized prompt or safe digest | Whether your application changed the tested input |
| Cache counters | Writes, reads and ordinary input | What the route reported |
| Crazyrouter route behavior | Request IDs and timestamps | A traceable case for investigation, not an inferred upstream cause |

Tool definitions and system content can affect the reusable prefix. Preserve the actual tool invocation and result sequence when compacting history; the tool-use ID guide shows the pairing checks. A broken conversation and a cache miss are different failures.
For OpenAI-compatible Chat Completions, inspect the appropriate cached_tokens field instead of renaming Claude fields. See the separate three-request prompt-cache experiment and the protocol comparison.
Report limits without losing the useful result#
This result replaces neither a production hit-rate study nor account billing reconciliation. We tested one synthetic prefix and one selected Claude model. The four wall times were 2.934, 2.378, 2.053 and 2.337 seconds; a miss was faster than the observed hit, illustrating why timing alone is inadequate.
The earlier October 11 experiment in this article used a different prefix and regional origin. Its 5,424-token counters must not be relabeled as this new run. Current conclusions use the November evidence above. Store request metadata using purpose-limited telemetry, without retaining customer prompts unnecessarily.
FAQ#
Why did the first request have zero cache reads?#
It reported a new cache write for this run's unique prefix. The response still completed successfully.
Why did the unchanged prefix miss after changing the question?#
The test did not identify the cause. We retained the shared prefix digest and usage to make the observation traceable.
Should I switch to a one-hour TTL?#
Not on this evidence alone. No expiration or one-hour retention test was performed here.
Can I prove a cache hit from response speed?#
No. In this sequence a request reporting a miss was faster than the request reporting a hit.
Does the cached prefix include my whole conversation?#
Do not assume it does. Follow the documented breakpoint and prefix rules, and inspect the counters for the actual request.
Do cache reads remove output charges?#
No such billing claim was tested here. Reconcile input, cache categories and output under your actual billing rules.
Implementation Guides
Podcast
AI Dev Tools: The Crazyrouter Podcast
Short episodes for developers on AI APIs, gateways, cost control and coding tools.
Latest episodes
EP196 · Oct 29, 2026 · 6:53
AI API Security Posture — Turn Controls Into Continuous Evidence
A practical guide to AI API security posture: inventory exposure, verify controls continuously, protect keys and data, constrain tools, and turn security assumptions into evidence that operators can act on.
EP195 · Oct 28, 2026 · 7:21
AI API Policy Drift — Detect When Production Rules Stop Matching Intent
A practical guide to policy drift in AI APIs: version routing and safety rules, detect stale enforcement, compare intended and observed behavior, and restore control before small gaps become incidents.





