All field notes
Model intelligence 7 minute read

Prompt caching and AI cost: what to measure

Understand when repeated context can benefit from caching and how to measure savings without assuming every request is cacheable.

In brief

  • Measure stable prefix reuse before forecasting savings.
  • Track cached and uncached tokens separately.
  • Do not trade correctness for cache shape.
01

Caching is a workload property

Long system instructions, tool definitions, and shared documents can create a repeatable prefix. Per-user conversations and freshly retrieved context may change too often to reuse effectively.

02

Measure the cacheable share

For each workload, estimate stable input tokens, variable input tokens, output tokens, repetition frequency, and expiration behavior. Use observed cache hits when available rather than treating all input as discounted.

Workload cache profile
InputQuestion
Stable prefixHow many tokens repeat exactly?
ReuseHow often before expiry?
VariationWhat invalidates the prefix?
OutputDoes generation dominate cost anyway?
03

Design context for correctness first

Group stable instructions consistently when the provider's cache semantics reward it, but do not omit current data or overload a giant static prompt solely to improve a hit rate.

04

Verify savings in usage records

Compare matched traffic before and after the change. Track quality, latency, cached tokens, and actual billed cost together so apparent savings do not conceal regressions.

Frequently asked

Questions, answered plainly.

Does prompt caching make every request cheaper?+

No. It depends on provider support, exact workload shape, repeated prefixes, timing, and current pricing.

Can semantic similarity create a cache hit?+

Provider prompt caches commonly depend on exact or provider-defined prefix reuse, not general semantic similarity. Check the active provider contract.

Should I make prompts longer for caching?+

Only when the added context improves the task. Optimize correct context first, then its stable layout.

Sources and next paths

Check the living surfaces.

Put it to work

One interface. Your choice of model.

Run the same task through live GPT, Claude, Gemini, and Xpersona models without rebuilding your client.

Try Xpersona chat
Prompt caching and AI cost: what to measure | Xpersona Blog