Essays / cost / caching
Prompt Caching Is Not a 60% Discount
The published saving assumes a workload almost nobody has. Here is what caching gave me over six weeks, and the three habits that decided whether it paid.
The pricing page says cached input costs a fraction of fresh input. I read that as "my bill will drop by roughly that fraction". Six weeks of measurement says otherwise: caching is not a discount, it is a property of your prompt structure, and you either have it or you do not.
Across 61 sessions in one project, my effective cache hit rate was 47%. That translated into a 31% lower input bill than the same traffic would have cost uncached. Real, worth having, and nowhere near the headline.
The arithmetic nobody does
Cache pricing is per token, but the discount only applies to the cached prefix. If half your tokens are in the prefix and you hit the cache half the time, the saving is 25% of the eligible portion, not of the bill.
More precisely: saving = prefix share x hit rate x discount rate. Four numbers, and the one people control is the second. My hit rate went from 23% to 61% in one afternoon by changing where I put the parts of the prompt that change.
The rest of the bill: output tokens, retrieval, and retries. None of them are cached, ever. In my sessions, cached-eligible input was 34% of total spend. Even at a perfect hit rate, the ceiling was a third of the bill.
What moved the hit rate
Freeze the top. Instructions, tool definitions, conventions, examples, in that order, never edited mid-project. Every edit anywhere in the prefix invalidates everything after it.
Move the variable parts down. Task-specific context, retrieved files, the user's message: below the static block. If your dynamic bits are above your static bits, you have a cache that misses on every turn.
Do not rebuild the prompt. The tempting refactor is a function that assembles the whole prompt from parts each turn. Convenient, and it changes the token sequence just enough to miss. I now hold the static prefix as one literal string and append.
Watch the TTL. Caches expire. A team that works in bursts of forty minutes separated by two hours of meetings gets a worse hit rate than one that works continuously, on identical content. If you can batch a project's interactive work into one window, do.
The two cases where it did not pay
- Short sessions. Under about eight turns, the prefix never gets read back. Caching only pays on reuse.
- Code-heavy work with a changing toolset. Adding a tool mid-session shifts the whole schema block. Either freeze the toolset for the project or accept the miss.
Measure the hit rate, not the discount. The number that matters is the fraction of input tokens that were served from cache. One field in your log. If it is under 40%, the problem is prompt structure, not the model, and no amount of model switching will fix it.
What I do now
- Static prefix as one literal string: instructions, tools, conventions, examples.
- Dynamic content appended, never interleaved.
- Hit rate logged per session, target 60%.
- Cost per accepted change tracked weekly, so I can tell "big week" apart from "wasteful week".
The bill went down 31%. The bigger effect was on latency: cached turns come back faster, and a faster loop changes how you work more than a cheaper one does.
What to steal
- Compute your ceiling first: what share of your bill is even cacheable. For most setups it is a third or less.
- Freeze the prefix, append the rest.
- Log the hit rate. Chase it to 60%. Stop there.
- Judge the result by cost per accepted change and by latency, not by the invoice.