A Practical Guide to LLM Prompt Caching and Reduced Cache-Hit Pricing
This article explains why major LLM services now price cached input tokens separately and offer steep discounts on cache hits, and what that means for developers. It covers how prompt caching works, the common conditions that determine whether a request hits the cache, and how to structure prompts to maximize hit rates by placing stable content first and variable content last. It also includes a method for estimating cost savings, observability metrics for validating results, engineering considerations around price-change effective dates, and a checklist of cache-friendly architecture practices.
1. Background and a Neutral Reading of the Announcement
A cloud provider recently announced that, starting at 00:00 Beijing time on November 23 of the following year, it will reduce the price of certain billing items for a general-purpose large model service on a node in one region. Specifically, “cache-hit input” will be priced at 20% of the original rate, while all other billing items remain unchanged.
This article does not review or recommend any specific product. Instead, it treats the announcement as a typical technical signal: in mainstream LLM services, the cost structure on the input side is being broken down further, with the cache-hit portion priced separately and given a significant discount. For developers and enterprise users, this means that optimizations at the architecture level can translate directly into savings on the bill.
2. Why “Cache-Hit Input” Is Priced Separately
The cost of LLM inference comes mainly from two parts: the prefill computation over the input context (the prompt), and the token-by-token autoregressive decoding. The longer the input, the more compute the prefill stage consumes. In many real-world workloads, requests often share large blocks of identical context, such as:
- System prompts and role definitions;
- Lengthy business rules, compliance terms, and glossaries;
- Few-shot example sets;
- Original text fragments repeatedly carried in long-document summarization tasks.
Recomputing this shared prefix every time wastes compute. As a result, the industry has widely adopted prompt caching: the intermediate computation results (the KV cache) of a shared prefix are retained, and subsequent requests that hit that prefix reuse them directly, computing only the new incremental portion.
Since the cache-hit portion consumes significantly less actual compute than the non-hit portion, pricing it separately and offering a discount is a natural reflection of cost. The announcement’s approach of reducing only the cache-hit input price while keeping everything else unchanged is a complete expression of this logic.
3. General Conditions for a Cache Hit
To get the discount, you first need to understand the hit conditions. Although implementation details vary across platforms, the industry broadly agrees on the same prerequisites:
- Exact prefix match: The cache is keyed on the prefix of the token sequence and compared position by position from the first token. Any difference at any position causes everything after that point to miss.
- Order sensitivity: Content that is identical but in a different order is treated as a different prefix.
- Time-to-live window: Cache entries usually have a lifetime and are evicted after a period of inactivity.
- Capacity eviction: Cache space is limited, and cold data is evicted using strategies such as approximate LRU.
- Model and parameter isolation: Caches are generally not shared across different model versions or quantization configurations.
This leads to a key engineering conclusion: the core way to improve the hit rate is to put invariant content first and variable content last.
4. Prefix Design Practices for Higher Hit Rates
Suppose we want to build a knowledge-base question-answering service. The following compares a bad approach with a recommended one:
# Bad example: the timestamp comes first, so the prefix differs every time and the cache never hitsbad_prompt = f"""Current time: 2026-11-23 10:31:07You are an enterprise knowledge base assistant. Answers must cite sources.Knowledge base rules: {RULES}User question: {question}"""
# Recommended: static content first, dynamic content lastSYSTEM_PREFIX = f"""You are an enterprise knowledge base assistant. Answers must cite sources.Knowledge base rules: {RULES}""" # Long and stable, used as the cache prefixdef build_prompt(question: str, ts: str) -> str:return f"{SYSTEM_PREFIX}\nRequest time: {ts}\nUser question: {question}"
A layered strategy is recommended:
- Layer 1 (highly stable): role definitions, output format constraints, safety policies;
- Layer 2 (low-frequency updates): glossaries, business rules, and few-shot examples, managed by version;
- Layer 3 (changes every request): conversation history, retrieval results, user input.
Also avoid several common “cache killers”: prepending a random request ID, timestamp, or username to the start of the prompt; mixing multiple templates for the same business, which fragments the prefix; and frequently tweaking the system prompt without versioned gradual rollout.
5. A Method for Estimating Cost Savings
Assume a scenario with an input size of 8,000 shared-prefix tokens per request, 500 incremental input tokens, and 100,000 requests per day. If the cache hit rate rises from 0 to 70%, the actual billed volume for the shared-prefix portion drops by about 70%. Under the rule that “cache-hit input is billed at 20% of the original price,” the cost of this portion becomes approximately:
0.7 × 20% + 0.3 × 100% = 44%
That is, spending related to the shared prefix drops by about 56%. Note that this is only an illustrative estimate; real savings depend on the hit rate, the cache lifetime window, and the traffic distribution, and must be based on actual bills and load-test data.
6. Observability and Validating Results
Optimization should not rely on guesswork. It is recommended to establish three categories of metrics:
- Hit-rate metrics: cache-hit tokens / total input tokens, broken down by business line;
- Latency metrics: percentiles of time to first token (TTFT) and overall latency; a hit is usually accompanied by lower TTFT;
- Cost metrics: cost per request and cost per thousand tokens, aligned with the price-change effective time for year-over-year comparison.
Validation can use a gradual rollout: first enable the new prefix structure on a small traffic share, compare the hit rate and the bill, then gradually increase the volume. During load testing, distinguish cold start from steady state to avoid drawing wrong conclusions from cold-start data.
7. Engineering Considerations Around the Price-Change Effective Date
For architects, the practical impact of a price-adjustment announcement concentrates on three points:
- Changes in billing definitions: confirm how billing items are split, regional differences, and the effective time, to avoid reconciliation discrepancies caused by time zones;
- Region and multi-active deployment: announcements often cover only a specific region, so multi-region deployments need to rebalance capacity and cost;
- Regression validation: a price change does not alter API semantics, but it is still advisable to run a link regression once before and once after the effective date to confirm there is no abnormal retry amplification of costs.
8. A Checklist of General Architecture Recommendations
- Manage prompts as “versionable configuration assets” in a code repository;
- Set a clear update cadence and gradual-rollout strategy for the static prefix;
- Assemble prompts centrally at the gateway layer, and prohibit individual business teams from assembling their own;
- For extra-long-context tasks, prioritize reusing shared fragments to reduce repeated prefill;
- Build a cost dashboard and treat the hit rate as a first-class metric;
- Add a “cache friendliness” check item to architecture reviews.
9. Conclusion
Pricing cache-hit input separately at a lower rate essentially makes the waste of “repeated computation” explicit and puts a price on it. For developers, the real benefit does not belong to bystanders, but to those willing to restructure their prompts and design stability into their systems. Put the invariant content first and the variable content last, combine this with an observable metrics system, and cost optimization turns from a one-time price-change windfall into a sustainable engineering capability.
