December 2, 2026•3 min read

Why Is Your Prompt Cache Hit Rate Zero?

Twenty-four turns, 164,854 tokens, not one cache read, and a bill 21% above the same loop with caching off. The prefix was changing every turn, and the line that changed it was in the tools array.

Read in Indonesian

A cache read happens only when the request prefix, up to the cache breakpoint, is byte-identical to an earlier request. One changing character voids everything before the breakpoint: a timestamp inside a tool description, today's date in the system prompt, or a breakpoint parked on the block that grows every turn. This loop sent 164,854 tokens across 24 turns and read back zero.

What counts as a hit?

The provider stores the prefix up to the breakpoint. A read is cheap, a write costs more than an ordinary token, and a miss costs nothing extra — it just bills the whole prefix again. So the question is never "is caching on". It is "is my prefix stable", and one unstable byte makes the answer no for every request after it.

What does 0% look like in numbers?

Output
$ make demo
One ticket at a time, caching on as it ships today:

  T-1041                 turns=8   sent= 54,960  read=      0  hit=  0.0%  $0.1614
  T-1042                 turns=8   sent= 54,960  read=      0  hit=  0.0%  $0.1614
  T-1043                 turns=8   sent= 54,934  read=      0  hit=  0.0%  $0.1613

  all three tickets      turns=24  sent=164,854  read=      0  hit=  0.0%  $0.4841
  same run, cache off    turns=24  sent=164,854  read=      0  hit=  0.0%  $0.4017

  cache reads cover 0.0% of the tokens sent, and the bill is 1.21x the no-cache bill.

The bill is higher than running with no cache at all. That is the part teams notice last: the feature is not failing quietly, it is charging a premium for writes nobody reads.

Which line breaks the prefix?

Output
$ make check
  [RED  ] A. cache reads cover at least 75% of the tokens you send  (hit rate 0.0% of 164,854 tokens)
  [RED  ] B. the run costs at most 45% of the same run with caching off  ($0.4841 vs $0.4017 (121%))
  [RED  ] C. the static prefix is identical on two different days, and the date still reaches the model  (prefix identical=False, 2026-11-09 in last block=False)
  [RED  ] D. each request is the previous one plus new blocks (nothing is rewritten)  (rewritten in 3 of 3 tickets)
  [RED  ] E. the tools array is identical on every request  (24 distinct tools blocks across 24 requests)
  [RED  ] F. the turn after the ten-minute pause still reads the static prefix  (T-1041: 0, T-1042: 0, T-1043: 0)
  [RED  ] G. the loop prints its measured turns, hit rate and cost  (no `summary turns=… hit_rate=… cost_usd=…` line on stdout)

Check E is the expensive one: 24 distinct tools blocks across 24 requests means the tool definitions were serialised fresh every turn, so the prefix never matched. Check D is the second: rewriting the transcript moves the breakpoint and buys nothing, because a rewritten prefix is a new prefix.

What actually fixes it?

Make the tools array a constant. In the answer article that single change took the hit rate to 78.4%. Moving the clock out of the system prompt, and the breakpoint off the growing block, changed nothing on their own. With all three the loop reaches 90.9% at 34% of the no-cache bill. The eight measured stages are in The Breakpoint Was on the Wrong Block.

How do you check your own loop?

Log the tokens read from cache on every request. If reads stay at 0 while writes repeat, dump two consecutive requests and compare them from the first byte — the first offset that differs is your breakpoint problem. If reads are non-zero but small, the breakpoint sits on a block that changes, and the transcript is the usual suspect. The pause in check F is the same shape of problem: a five-minute write expires before the next turn arrives, so an idle loop pays for the prefix twice.

The lab is inva-lab 0006, and the story behind the numbers is A 6,000-Token Handbook and a 0% Cache Hit Rate.

Cache the blocks that never change, put the breakpoint after them, and move anything with a clock to the block that comes last.

Get better at shipping code.

Join the other developers getting tech updates, tips, and relaxed tutorials in their inbox every week.

Stay in the loop

Tech updates, coding tips, and relaxed insights straight to your inbox every week.

No spam. Unsubscribe anytime.

Read next

See all
WebhookEvery Write Comes Back as News

A supplier file says the mug is gone, the app drafts it, the store puts it back, forty times. Seven checks, and the eager webhook handler is only the second problem.

WebhookThe Status That Changed Itself

A product's status blinks between published and draft, nothing errors, and the guard you wrote first works right up until it doesn't. The loop was never an echo.

For developers who learn by struggling

© 2026 Inva.dev.