You change one word in the system prompt and prompt caching breaks. Why?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Caches key on exact token ids, not meaning. One changed word shifts ids from that point forward, invalidating every KV tensor after it because attention at position N depends on all earlier positions.
Imagine a long shared road the model drives down for every request. Once the model has driven a mile, the road behind has cone markers showing it has been measured. The next driver can skip the measured section. Now suppose someone moves a single cone earlier in the road. Every cone past that point is suspicious; the next driver has to re-measure from the moved cone onward. The cones are the cached KV values, the road is the token prefix, and moving a cone is what happens when you change a single character in the prompt.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: explain the cache as a token-id prefix store, walk through why a single id change invalidates everything after it, contrast Anthropic explicit breakpoints with OpenAI automatic caching, and close on the stable-prefix volatile-suffix design rule.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Putting dynamic content (user question, timestamp) at the start of the prompt and the long static system prompt at the end. The first token differs every call, so the cache hit rate drops to zero.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.