Understanding Prompt Caching Billing: Cost Model and Engineering Practices
This article breaks down how prompt caching is billed and why it can look like a hidden "cache tax." It explains the three billing actions—base input, cache writes, and cache-hit reads—and uses a simple cost ratio model to show that caching is a prepaid cost amortized by reuse, not a discount. It then covers practical steps to raise hit rates and architecture tips for layered caching and neutral platform selection.
1. The Phenomenon: A “Hidden Fee” on the Bill
As an overseas LLM platform went public and drew strong investor enthusiasm, many frontline developers were reading a different story on their bills: the same system prompt, the same codebase context, and the same tool descriptions were being sent and billed over and over. As long as content is “cached” and reused, it seems you pay an extra, hard-to-notice fee—something the community has jokingly called a “cache tax.”
To judge whether this is the secret to a platform’s high margins, you must separate two things: the compute cost the platform actually saves, and the perception created on the developer side by the pricing structure. The two are not equivalent, and conflating them leads to wrong conclusions.
2. Mechanism Breakdown: Caching Billing Splits into Three Independent Actions
Prompt caching is a common industry practice: frequently repeated prefix content—system prompts, role settings, tool declarations, long documents, codebase snippets—is computed ahead of time and stored, so later requests reuse it directly instead of reprocessing from scratch each turn. For the platform, this significantly reduces the compute overhead of repeated work; for developers, it should mean something cheaper.
But mainstream billing schemes usually split this into three actions, each with a different multiplier (the multipliers below are illustrative industry-typical values, not a specific vendor’s pricing):
| Billing item | Multiplier relative to base input | Notes |
|---|---|---|
| Base input | 1.0x | Regular input that misses the cache |
| Short-lived cache write | ~1.25x | First write, kept for a short time |
| Long-lived cache write | ~2.0x | First write, kept longer |
| Cache-hit read | ~0.1x | Reuse of an already-cached prefix |
The rule is not complicated: the first write costs about 25% or even 100% more than regular input; after that, each hit charges only one-tenth of the base input; and the cache has an expiration, after which it must be written again—meaning you pay the write premium once more. The platform does not pass on the full compute savings; it first charges a “storage fee,” then offers a “reuse discount.”
3. Cost Model: Using Hit Rate to Judge Whether the “Excess Profit” Is Real
Let the base input unit price be P, the write multiplier be a, the hit multiplier be h, and a prefix be reused n times within a session. The total cost relative to “no caching at all” can be approximated as:
ratio = (a + (n - 1) * h) / n
Plugging in a=1.25 and h=0.1:
- n=1: ratio=1.25, more expensive than no caching;
- n=2: ratio≈0.675;
- n=5: ratio≈0.33;
- n=20: ratio≈0.1075.
The conclusion is clear: caching is not a discount coupon, but a prepaid cost that must be amortized by the number of reuses. When the hit rate is insufficient, the bill inevitably rises; when the hit rate is high enough, the cost can drop by an order of magnitude. Much of the so-called “excess profit” comes from the write premium in high-volume, low-frequency, short-session scenarios—an illusion created by the pricing structure, not all real money.
4. Engineering Practices: Raising the Hit Rate
- Prioritize prefix stability. Move volatile content (timestamps, random IDs, user input) to the end, ensuring the prefix is byte-for-byte identical; otherwise the cache cannot hit.
[Stable prefix] System prompt + tool declarations + long document[Semi-stable section] Codebase retrieval results[Volatile suffix] Current user question
- Control cache granularity. Too short leads to frequent paid writes; too long crowds out quota and lowers the reuse rate. Choose values based on measured session length and reuse counts.
- Align expiration with session rhythm. The short-lived tier suits one-off tasks; the long-lived tier suits interactive development that lasts tens of minutes.
- Build observability. Use logging services and monitoring alerts to track hit rate, write counts, and average reuse turns, attributing cost to specific business flows.
- Set budget guardrails. Apply quotas and alerts to high-multiplier writes to avoid write storms caused by abnormal retries.
5. Architecture Recommendations: Layered Caching and Neutral Selection
On the application side, you can introduce semantic caching and result caching to form layers alongside the platform’s prefix caching; for long documents, combine object storage with vector retrieval to reduce the context size assembled each turn. When selecting, focus on general capability categories—model serving, caching and batch processing, logging and monitoring, containerized deployment and elastic scaling—rather than being led by a single product’s marketing. General cloud product categories offered by providers such as Baidu AI Cloud can serve as reference dimensions for comparison.
6. Conclusion
The “cache tax” is not a hidden charge, but a re-pricing of compute savings along the dimensions of time and reuse. The right approach for developers is not to resist caching, but to amortize the prepayment using hit rate, reuse turns, and expiration policies; enterprises should bring caching costs into an observable system and judge platform margins with data rather than emotion.
