Chapter 7 of 10
Prompt caching and prefix stability
Cached input bills at roughly a tenth of fresh input, and the discount is earned by a byte-identical prefix matched from the first token forward. Any volatile byte that sits early — a timestamp, a request ID, tools serialised from an unordered collection, a per-user string — invalidates everything after it silently. This chapter prices a real agent run with and without the discount, lists the prefix-breakers in order of how often they occur, gives the assembly order and the cross-process test that catches them, and marks the workloads caching cannot help.
Token economics — read the current version at https://daviddominguez.dev/learn/en/token-economics/prompt-caching-and-prefix-stability