‹ Back to Orbis News
Guides

How to use prompt caching and troubleshoot cache misses

Prompt caching reuses computation from repeated input. Put stable content first, then check actual cache reads and writes to see whether it reduces your application’s costs.

Orbis News6 min read
Transparent blue data tiles enter a cache box while changing orange tiles continue ahead

Which tasks benefit from prompt caching?

Prompt caching suits API tasks that repeatedly send the same long prefix: put fixed instructions, tool definitions and reference material first, place the current question last, then check cache usage in the response. It reuses computational state from the input; each request still has to generate an answer. Before integrating it, confirm how your provider, model and API support caching. A successful request alone does not prove a cache hit.

For example, answering different users’ questions from the same product manual or repeatedly sending the existing conversation with a multi-turn assistant gives you material to reuse. By contrast, if each request contains entirely new, short text, enabling caching may not provide a long enough shared prefix.

OpenAI’s official documentation describes the cached content as the prefix’s key-value states (KV states). Think of these as intermediate computational results left after the model reads that input. vLLM’s APC documentation makes a further distinction: caching primarily saves input prefill computation; it does not reduce the time spent decoding new tokens. Long inputs with short answers may therefore be a better place to start optimizing. If long outputs account for most of the time, caching cannot deliver the entire speedup. This is an assessment of the mechanism, not a speed measurement conducted for this article.

Arrange the stable prefix before choosing cache parameters

Caching generally requires an exact prefix match. “Roughly the same meaning” is not enough. If earlier content or a relevant configuration changes, even identical content later in the request may no longer be reusable.

Inspect the request your application actually sends, rather than just the prompt in your editor. SDKs, agent frameworks and gateways may add tool definitions, formatting requirements or other context. Putting a timestamp before the fixed instructions on every turn may look like a one-line change, yet remove the shared prefix for a large body of reference material.

The following is a request-organization checklist prepared for this article, not an API request you can submit directly or the result of a test run:

  1. Keep tool definitions and their order stable. Avoid unintentionally rearranging names, descriptions and parameters.
  2. Place fixed task instructions, output constraints and shareable reference material first. Do not add unnecessary material just to enable caching.
  3. For APIs that support explicit breakpoints, place a breakpoint at the end of the stable content you want to reuse.
  4. Place changing content, such as the current question, timestamps and retrieval results, later in the request, while preserving permissions and the instruction hierarchy.
  5. For multi-turn tasks, append new messages where possible. When compression or corrections are needed, accept the corresponding cost of rebuilding the cache.

“Stable” here applies only to the group of requests that should share a cache. Do not mix different users’ permissions or different knowledge-base versions to chase cache hits. When a version changes, use the new content. Accuracy comes first.

If your application also requires fixed JSON fields, start with our guide to choosing structured output methods. The schema is part of the request, so review format design and cache design together.

Do OpenAI, Gemini and cloud services follow the same rules?

You cannot copy one API’s parameters into every “compatible” service. As of 2026-10-31, the official documentation sets out the following boundaries:

  • OpenAI API
    • What to check first: The current model’s supported implicit/explicit modes, minimum prefix and TTL
    • Common source of confusion: Applying older models’ parameters and cache-write billing rules to newer models
  • Gemini Interactions API
    • What to check first: Only implicit caching is supported; check the specific model’s threshold
    • Common source of confusion: Copying an older generateContent tutorial that uses explicit cache objects
  • Azure OpenAI
    • What to check first: Model generation and deployment type
    • Common source of confusion: Standard and PTU-M differ in their support for explicit breakpoints
  • Amazon Bedrock
    • What to check first: Model, region, API used and cache type
    • Common source of confusion: Treating one model’s cache checkpoint as a universal parameter
  • Self-hosted vLLM
    • What to check first: The deployed version and APC configuration
    • Common source of confusion: Using the name of a server-side feature as a request field for a hosted API

For example, OpenAI’s current guide lists a minimum cacheable prefix of 1,024 visible input tokens for GPT-5.6 and later models. In explicit mode, you must actually set a breakpoint. Setting the mode to explicit without any breakpoints does not use prompt caching. This rule does not apply to all older models.

Google’s current caching documentation states that the Interactions API supports only implicit caching, and Gemini 4 Argon and later do not support explicit caching. The page lists a minimum input threshold of 4,096 tokens for Argon. “Anything over 1,024 tokens can be cached” is not a rule that applies across providers.

These thresholds count tokens, not Chinese characters or characters in general. Near a threshold, verify the count using the target API’s counting method. If the reference material is short and rarely reused, keep the request short instead of padding it with repeated content. Compare input spending and results for the complete task.

How can you verify a cache hit?

Check cache-read usage first, latency second and task cost last. “The second request felt faster” is not evidence: network conditions, queuing and output length can all change the total request time.

Usage fields differ across APIs. The OpenAI Responses API reports cache reads in usage.input_tokens_details.cached_tokens; newer models with the corresponding billing support also report cache_write_tokens. Gemini Interactions uses usage.total_cached_tokens. The Bedrock Converse documentation reports cacheReadInputTokens and cacheWriteInputTokens separately. Do not simply add fields from different services together without accounting for their meaning.

In an environment where you are authorized to make requests, you can use the following sequence. We did not run these requests for this article and do not provide invented cache-hit results:

  1. Choose a long set of instructions or a document that will actually be reused. Keep the model, API and configuration fixed.
  2. After the first request, record input usage, cache writes, cache reads and request time.
  3. Within the cache’s validity period, preserve the stable portion, change only the task-specific question at the end and send representative requests.
  4. Compare read and write usage across multiple calls, and check answer quality and spending for the complete task.

A first request that writes to the cache but records no cache reads is not unusual. Subsequent requests are not guaranteed to hit every time, either. For requests containing private information, record the prefix version and necessary usage metrics. Do not log complete user inputs in public logs just to debug caching.

What should you check when prompt caching misses?

Start with what you can verify locally, then check service status. The following order is based on official prefix-matching requirements; it does not imply that any particular failure is the most common.

  • Both reads and writes are zero
    • Check first: Whether the model/API supports caching, whether the stable portion is long enough, and whether explicit mode has a breakpoint
    • Next step: Check the service’s current documentation and confirm the actual request structure
  • Writes on every request, but almost no reads
    • Check first: Whether timestamps or random IDs precede stable content, or tools or the schema have changed
    • Next step: Compare two redacted requests and find the earliest difference
  • Identical content misses after an interval
    • Check first: The actual TTL, reuse interval, and changes to the model or service routing
    • Next step: Check the interval; do not simply extend every cache’s lifetime
  • Reads suddenly decrease after appending turns
    • Check first: Whether earlier messages were rewritten, history was compressed, or the reusable boundary moved
    • Next step: Preserve stable blocks and check how the API searches for breakpoints
  • Cache hits produce no clear drop in total time
    • Check first: Output length, queuing and network time
    • Next step: Examine time to first token and completion time separately

Supported OpenAI Responses models also offer cache diagnostics, which compare the current request with a previous response to identify causes such as changes to the model, tools or input. Availability depends on the model. unavailable means no conclusive diagnosis was obtained; it does not mean a cache hit.

If you use a gateway, also check whether it passes cache parameters through and preserves the corresponding usage fields. Chat API compatibility does not imply identical caching capabilities. If read statistics are missing, record the outcome as “not yet verifiable” rather than claiming that a cost-saving percentage has been achieved.

Evaluate complete tasks, not just hit rates

Cheap cache reads do not mean every write is cheap. OpenAI’s current documentation distinguishes cache-write rules for newer and older models. Azure’s documentation also notes that newer models may incur cache-write charges. If a large prefix is written once and never reused, extending its TTL does not automatically make it economical.

Keep a simple evaluation sheet for comparable tasks: completed task count, input usage, cache reads and writes, output usage, failures and retries, actual charges, time to first token and total completion latency. Keep the task scope fixed when comparing results so that shorter answers are not mistaken for caching gains.

Context compression involves the same trade-off: it may reduce reuse of the old cache while reducing the input carried into later requests. Judge it by task cost and quality before and after compression, rather than requiring the hit rate alone to keep rising.

Caching also cannot replace rate limiting and reliability design. OpenAI’s current documentation explicitly states that cached input still counts toward TPM limits. For 429 errors, follow the separate steps in our guide to troubleshooting API rate limits and retries. Check other platforms’ quota rules separately.

Start by fixing the earliest changing part of the prefix, then verify the result with real usage data. Prompt caching is integrated successfully when you can confirm reuse, understand when it expires and account for spending on the complete task.

Further reading

This article reorganizes the following official sources into an integration and troubleshooting workflow. It includes no API performance tests and makes no guarantees about cache hit rates or savings.