Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Prompt caches only hit on byte-stable prefixes, so the system prompt should hold turn-invariant content (persona, policies, tool schemas) and never per-call values like timestamps or user ids.
Imagine a coffee shop that pre-makes your standard order the moment you walk in, but only if you ask for the exact same thing every time. Change one word, say, oat milk instead of whole milk, and the barista has to start from scratch. The shop's pre-make station is the prompt cache. Your standard order is everything in the system prompt that never changes: who the model is, what it can do, what shape its answer should take. If you sneak today's date or your username into that standard order, the barista throws out the half-made drink and starts over. The trick is to keep your standard order genuinely standard and ask for the day's specials at the counter instead.
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.
Define prompt caching and the byte-exact cache key. State the rule: only turn-invariant content in the system prompt. List what belongs (persona, policies, output contract, tool schemas) and what does not (timestamps, user id, feature flags, locale). Explain where per-call values go instead. Touch on cache breakpoints for layered prompts and the failure modes (template whitespace, dict ordering, build-time interpolations). Close with the observability point: surface cache-hit rate or you will not notice regressions.
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.
Sprinkling today's date, the active user id, or feature flags into the system prompt and silently destroying every cache hit on the application.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.