Claude API Prompt Caching Not Working? A Timestamp Made My Bill Go Up
▶ Watch on YouTube & subscribe to The Stack Underflow
I added prompt caching to a long system prompt, and the bill went up. One timestamp line at the top of the system prompt made every call a cache write, never a read: 22 to 27 percent more per call than no caching at all. The line the API sent back:
cache_miss_reason = system_changed
The one-line version: keep everything before the
cache_controlmarker identical, character for character; put the time, user names, request numbers and the question after it.
Tested: 16 November 2026 (claude-sonnet-5-5; Python SDK anthropic 2.8.0; effort low; in Docker). Newer versions may behave differently.
The words first
- Cache write: the first call stores the prompt up to the marker, at 1.25x the input price.
- Cache read: later calls with the same prefix read it back, at a twentieth of the input price on Sonnet 5.5.
- Prefix: everything before the marker. One changed character and it is a new prefix.
What the runs showed
One long style guide (Python’s PEP 8) in the system prompt, the cache_control marker after it:
| Setup | What happened | Cost |
|---|---|---|
| Baseline, no marker | 3,851 input tokens at full price | 0.857 cents a call |
| Marker, time in the question | call 1 writes 3,812 tokens; 20 s later call 2 reads 3,812, and input_tokens drops to 40 (only what comes after the marker) | call 1 22 percent more, call 2 84 percent less; three calls 1.33 cents vs 2.59 at full price |
| Marker, time at the top of the system prompt | 5 calls, cache read 0 every time, each a full write again | 22 to 27 percent more than no caching |
The field that names the cause
Send diagnostics with the previous reply’s id on every call. On the bug it named system_changed (plus cache_missed_input_tokens 3,891, which the docs call a rough estimate, not billed tokens). On the fixed version it came back null: nothing changed.
Too short to cache
A 71-token prompt with the marker: both cache fields 0, and no error. On Sonnet 5.5 the minimum cacheable prefix is 512 tokens. A kept copy lives 5 minutes by default, refreshed each time it is used.
What it cost
List price, 16 Nov 2026 (Sonnet 5.5: input $2, 5-minute cache write $2.50, cache read $0.10, output $10 per million tokens). The whole lab: $0.0855 (12 billed calls; token counts are free).
Your turn
A chatbot puts the user’s name at the top of its system prompt, then a 3,000-token guide, then the marker. Two users ask a minute apart. What is the second call’s cache read, and the fix? Reply in the video’s pinned comment.
The series
- Previous: #1: why is thinking empty? Effort vs thinking
- Next: #3: tool_use ids without tool_result blocks
Sources
Read 16 November 2026:
- Claude docs: Prompt caching
- Claude docs: Cache diagnostics
- Claude docs: Pricing
- Claude docs: Token counting
- PEP 8 (public domain), the style guide used as the long prompt
Change notes
- 20 Nov 2026: first published, from the lab results of 16 Nov 2026.
Not affiliated with or endorsed by Anthropic. Found a mistake? Tell us in the video’s comments and we’ll correct this page.
Found this useful? The deep version lives on YouTube — new breakdowns of how AI dev tools actually work, weekly.
Subscribe on YouTube →Prefer email? Get the free newsletter: one failure, traced step by step, about once a week.