Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Explain how prompt caching is priced by Anthropic and by OpenAI. What counts as a cache hit, what doesn't, and what should an application architect do to maximize hit rate?
Prompt caching reuses the KV state of a byte-identical prefix at a steep discount, so put stable content first and dynamic content last to maximize hit rate.
Imagine a coffee shop where the barista has to read your whole life story before every order, charging you per word. With prompt caching, the barista writes your fixed story (who you are, your usual notes) onto a card once, keeps it behind the counter, and only reads the new bit each visit. Reading the card costs almost nothing compared to re-reading everything. But the card only works if the story is word for word identical to last time. Change one comma at the top and the barista throws the card away and rereads it all. The card also expires after a few minutes of no visits. So you keep the unchanging part at the top, the new order at the bottom, and you visit often enough that the card stays warm.
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.
4 min: byte-identical prefix hit rule + Anthropic 10 percent read, write fee, TTL + OpenAI flat 50 percent auto + prompt ordering rule + savings math + high-impact workloads.
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.
Assuming any semantically similar prompt hits the cache. A hit needs a byte-identical prefix, so one changed token, reordered tool, or stray whitespace high in the prompt invalidates everything below it.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.