Prompt caching: measure the savings correctly
Account for writes, reads, misses, and model-specific thresholds before estimating caching savings.
A cache can reduce the cost of repeated prompt prefixes. The saving depends on the model’s read and write prices, the reusable prefix, and actual hits. It does not establish an overall application cost reduction by itself.
Current Claude behavior
The prompt-caching documentation describes automatic caching using a top-level cache_control field and explicit block breakpoints. Supported lifetimes include five minutes and one hour. Read multipliers and minimum cacheable lengths vary by model. Check the current table for the model and platform you use.
Log ordinary input, cache-creation input, cache-read input, and output usage. Distinguish a cache miss from a prefix that is below the model’s minimum. Select a lifetime based on the observed interval between reusable requests, then measure the write premium against the extra reuse.
A corrected calculation
The earlier article presented an unsupported customer measurement and an incorrect weighted average. The following is a hypothetical calculation, not a production result.
Assume:
- Each request has a reusable 50,000-token prefix.
- 80% of requests read that prefix at 0.1 times the base input price.
- The remaining 20% write it at 2 times the base input price.
The average prefix cost, expressed in base-price token equivalents, is:
50,000 × (0.80 × 0.10 + 0.20 × 2.00)
= 24,000 token equivalents per request
Prefix-only saving = 1 - 24,000 / 50,000 = 52%
This excludes variable input, output tokens, tool costs, and infrastructure. It assumes every miss writes the full prefix and the stated ratios apply. Change those assumptions and the result changes.
Break-even exercise
For an identical prefix written once at 2 times base price and subsequently read at 0.1 times, the cost over N requests is 2 + 0.1 × (N - 1) relative to one uncached request. Two requests cost 2.1 rather than 2; three cost 2.2 rather than 3. Savings begin on the third request under these assumptions.
Measure on your own request logs. Report prefix savings and whole-workload savings separately, with model, pricing date, and measurement period.