Urgent.News

What's breaking now, across thousands of outlets.

AI

Claude Prompt Caching Hit Rate Was 0%. One Timestamp Did It

I turned on Claude prompt caching, shipped it, and moved on. Nine days later I looked at the usage logs and saw cache_read_input_tokens: 0 on every one of 3,412 calls. Not a low hit rate. Zero. And it was worse than zero, because every one of those calls paid the cache write premium. Turning on caching had made my bill go up. The cause was one line: a timestamp at the top of my system prompt.…

Claude prompt caching hit rate was 0% on 3,412 calls, despite the cache write premium. The issue was caused by a timestamp in the system prompt, which made each request unique and not eligible for caching. After moving the timestamp to the end of the request, the hit rate improved to 78%, but stalled at 93% due to a second bug caused by Python's hash randomization. The fix was to sort the tools list to ensure consistent prefixes across worker processes.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

More from Tuesday 29 September →