Prompt caching, from the causal mask outward
Almost everything written about prompt caching is a list of rules. There is only one rule. A transformer’s work on a token depends on everything before it and nothing after it — and every breakpoint, every price, every trap in this post is deduction from that sentence.
Contents9 pages
Start here
IntroductionWhat an agent loop pays to resend an unchanged prefix every turn, and the one fact about attention this post derives the fix from.
Part 1 of 4
Why the cache is a prefixWhy the causal mask makes a prefix the only cacheable unit, what the cache holds, where a breakpoint cuts, and why a miss walks backward.
Part 2 of 4
Where the breakpoint goesThe placement that bills more than no caching, why the last block suits a growing loop, and how four breakpoints and the cascade divide a prompt.
Part 3 of 4
What it costs, and for how longBreak-even in two requests, a TTL that starts with the request, a per-model floor below which nothing caches, and the usage fields that show it.
Part 4 of 4
Running itWarming a cache without the fan-out trap, the sharp edges that break it silently, and the whole mechanism rebuilt from scratch in eighty lines.
After the parts
RecapEvery number, rule and trap from the post on one surface, laid out to be recalled at a glance rather than read.
After the parts
PracticeCards that walk the argument one step at a time: pick the answer from first principles, and a miss names the section to go back to.
Appendix
GlossaryEvery abbreviation and outside term the post uses, expanded in a line and ordered for lookup.
Appendix
ReferencesThe primary sources behind every number and claim, each with what you will find there, including the paper that complicates the argument.