Prompt Caching Strategies That Save Money
Prompt caching can reduce the cost of repeatedly sending the same instructions and reference material to a model. But a long prompt does not automatically produce savings. The reusable content must qualify for caching, requests must reach a compatible cache, and the pricing must reward reuse. Follow these steps to build a strategy you can verify on your bill.
#1 · Understand what you are caching
Prompt caching generally reuses processing for previously submitted input, often a matching prefix. It is different from saving a completed answer and returning it later. The model still generates a response to the current request, so output tokens remain a separate cost.
Start with repeated input: system instructions, tool definitions, document excerpts, and stable examples. A support assistant that uses the same product handbook across many questions is a better candidate than a collection of unrelated, short prompts.
#2 · Check the exact model and route
Before changing your application, check the documentation and pricing for your chosen model and API route. Look for minimum cacheable input length, retention rules, cache-write charges, cache-read prices, and any required request fields.
If you are evaluating Claude Haiku 4.5 or Gemini 2.5 Flash, check each independently rather than assuming identical behavior. Some caching is automatic; other implementations need explicit configuration. An OpenAI-compatible interface does not, by itself, establish that provider-specific cache controls are supported.
#3 · Put stable material before changing material
For prefix-based caching, place reusable content first and request-specific content last. A practical order is: fixed instructions, stable tool definitions, shared reference material, then the latest user question.
Avoid putting a timestamp, random request identifier, or changing user profile at the beginning. Those fields can break prefix matching before the reusable material starts. Keep necessary dynamic information, but move it after the shared section when semantics allow.
Do not pad prompts to reach a cache threshold. Extra tokens can increase costs without improving answers or producing enough reuse to justify them.
#4 · Keep the reusable prefix consistent
Treat shared prompt content like a versioned application asset. Keep formatting, document ordering, and tool schemas consistent between requests. Avoid rebuilding an unchanged reference section with different whitespace or shuffled entries.
Make deliberate updates when information changes. A stable but outdated handbook is not a useful optimization. Record a prompt version in your application logs so you can explain changes in cache performance without adding a changing value to the shared prefix.
#5 · Match reuse to retention
A cache helps only if another eligible request arrives while the content remains available. Check whether your workload repeats within the documented retention window and whether longer retention costs extra.
Do not send artificial requests just to keep a cache warm unless a measured cost comparison supports that decision. Where your application already processes a queue, grouping work that shares reference material may improve reuse, provided it does not compromise latency requirements or data boundaries.
#6 · Measure total cost, not just cache hits
Run a small test using representative traffic. Compare equivalent requests with caching enabled and disabled where the API allows it. Capture the provider's reported cache metrics and actual billing categories.
- Uncached input tokens and their charge.
- Cache-write or storage charges, if applicable.
- Cached input tokens and their charge.
- Output tokens, retries, and total request cost.
A high cache-hit rate is not proof of savings. Include cache creation costs and compare cost per successfully completed task. Also check answer quality: changing prompt order must not quietly damage results.
#7 · Preserve privacy and verify relay behavior
Follow documented cache-isolation and retention controls, especially for customer-specific content. Do not assume a shared prefix is safe to reuse across tenants merely because its text matches.
Relay365 is a pay-as-you-go relay desk for multiple model families and can fit teams testing different routes. It works with Claude Code, Codex, Gemini CLI, and OpenAI SDK clients. Before relying on caching through any relay, verify supported cache controls, routing behavior, usage reporting, and how cached usage is billed.
#8 · Start small, then expand
Choose one frequently repeated workflow and establish a baseline before rolling caching out broadly. If Relay365 fits your tooling, create an account and run that limited comparison first. Expand only when the measured savings justify the added configuration and monitoring.
Further desk bulletins
| Date | Bulletin title | Filed under | Language |
|---|---|---|---|
| 2026-10-25 | Summarising Meeting Notes With a Cheap Model | Spend watch | EN |
| 2026-10-25 | Prototype on a Small Top-Up Without Overspending | Spend watch | EN |
| 2026-10-25 | Stop Runaway Agent Loops Before Costs Climb | Spend watch | EN |
| 2026-10-25 | Cheap Models for Bulk Jobs, Strong Models for Hard Ones | Spend watch | EN |
| 2026-10-24 | Why Output Tokens Often Dominate AI Bills | Spend watch | EN |
| 2026-10-24 | How a Monthly Pass Quota Is Used, Request by Request | Spend watch | EN |
Curious how it runs on your own code? Sign up →