A cache that silently misses looks exactly like a cache that works: the request still succeeds, and you still pay full input price. The only sign is in the response usage fields. A request below the model’s minimum cacheable length is silently not cached, and both cache_creation_input_tokens and cache_read_input_tokens come back as 0 with no error. Always verify by inspecting the response.
Prerequisites
- Two requests with the same prompt prefix.
- Access to the response usage fields.
- A note of the model’s minimum cacheable prefix length.
Steps
Step 1: Send two identical prefixes
Send the first request to write the cache, then send a second request with the same prefix and a new question. The prefix must be identical: one changed token means a miss.
Step 2: Read the usage fields
Read the second response’s usage fields. Cache_read_input_tokens above zero means the prefix was read from cache; cache_creation_input_tokens above zero on the first request means it was written.
Step 3: Fix a zero read
If the read is zero, check three things: the prefix is identical, the prefix is longer than the model’s minimum cacheable length, and the second request arrived within the cache lifetime. Fix the cause and test again.
Worked example: Harbor Light library catalogue questions
The fictional Harbor Light library sends the same 2,000-token catalogue guide twice, with a different question each time.
| Response | Cache creation tokens | Cache read tokens | Verdict |
|---|---|---|---|
| Request 1 | 2000 | 0 | Cache written |
| Request 2 | 0 | 2000 | Cache hit |
| Request 3, changed prefix | 2000 | 0 | Cache miss: prefix changed |
Request 2 reads 2,000 tokens from cache, confirming the hit, while request 3 with a changed prefix reads 0 and writes the cache again.
Expected result. The usage fields show a cache read above zero on the second request, and a changed prefix shows a miss. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.
Limits
- The usage field names differ by platform; the Claude API uses cache_read_input_tokens and cache_creation_input_tokens.
- A zero read is silent, not an error; you must look for it.
- This guide does not cover the cost math of caching.
