If a Claude request through CometAPI keeps reporting cache writes but no reads, check where the breakpoint sits before making the reference document longer. A repeated document is not enough if the only cache entry also includes a timestamp or a different question on every call.
This is specifically about independent questions over a shared reference, not an append-only conversation.
Why lookback may not rescue the reference
Anthropic’s prompt-caching guide distinguishes two operations: a write stores the cumulative prefix ending at a marked block; a read searches for a matching entry that an earlier request actually wrote.
Its example has stable blocks 1–5 and a changing timestamp/user-message block 6. With the only breakpoint on block 6, the first request writes an entry that includes the timestamp. The next request changes that prefix. Looking backward to block 5 does not help: no entry was written there.
The correction is to mark block 5, not to assume lookback discovers and caches stable material automatically. Everything up to and including that block must remain identical.
Apply that boundary to CometAPI Messages
CometAPI’s Cache prompts example already demonstrates the useful separation: reference text in a system content block with cache_control, and a question in messages. It uses the Anthropic SDK against https://api.cometapi.com, via POST /v1/messages.
For that integration, keep the reference block stable and put changing request context after its breakpoint. The relevant request-body fragment is:
{
"system": [
{
"type": "text",
"text": "<unchanged reference material>",
"cache_control": {"type": "ephemeral"}
}
],
"messages": [
{
"role": "user",
"content": "<this request's question and any changing timestamp>"
}
]
}
This is a structural fragment, not a complete runnable request. Replace the placeholders with actual content, retain the model and other required fields from the CometAPI example, and use a reference prefix that meets the selected model’s minimum cacheable length. The short placeholder above would not establish a meaningful cache test. CometAPI’s cache example uses claude-sonnet-5; this placement advice is about its documented Claude Messages format, not a claim of cache compatibility across other model APIs.
Test placement, not several variables at once
My suggested check is two sequential requests through that same CometAPI Messages integration:
- Send the reference with the breakpoint on its last stable block. Wait for the completed response and record its usage counters.
- Promptly send another request, changing only the question after that breakpoint. Keep the model, reference, thinking settings and effort configuration unchanged.
- Compare
cache_creation_input_tokensandcache_read_input_tokens. CometAPI documents the former as tokens written to cache and the latter as tokens read from it. A positive read counter is evidence of reuse; another write alone is not.
If reads remain zero, inspect the entire prefix—not just the marked block—for changes. Then check the selected model’s minimum length and the timing between requests. Anthropic documents a default five-minute ephemeral lifetime and notes that a cache entry becomes available only after the first response begins. A prompt below the minimum can skip caching without an error, so zero writes and zero reads is a different clue from repeated positive writes.
This is a documentation-based diagnostic, not a reported CometAPI benchmark. Correct placement removes one avoidable source of misses; it does not establish a hit, a bill reduction, or a latency improvement until the actual integration is measured. For this workload, the first decision is simple: write an entry for the reference you intend to reuse, rather than for the reference plus today’s question.