Exact-match gateway caching: latency and cost saved

A cache hit in the AcruxCore gateway returned in a median of 9 ms, against 902 ms for the same call sent to the provider, and it cost $0. The test sent each of 15 prompts four times, so 3 of every 4 calls were repeats, and caching cut spend by 75%.
A gateway virtual key
can be given a cache window: set
cacheTtlSeconds and
an exact-match repeat of a call — same model, same messages, same sampling
parameters, tools and response format — is served from Postgres instead
of the provider. We ran the same fixed set of prompts through it repeatedly
to see what a hit is actually worth, in milliseconds and in dollars.
The setup
Fifteen distinct one-word-answer prompts, sent through gpt-4o-mini with
temperature: 0. The cache never stores a call with an omitted or non-zero
temperature, for the reason given below. Each of the 15 prompts was sent four
times. The first send of a prompt is a cache miss, and the three repeats that
follow are hits, because nothing in the request changed. That is 60 calls in
total, on a virtual key created for this run with a five-minute cache window.
- Date: 1 August 2026.
- Gateway host, region, Postgres location and gateway version: not recorded.
The benchmark script's default base URL is
http://localhost:3001/api/v1, andACRUXCORE_BASE_URLpoints it at another gateway.
The latency gap
| n | median | p95 | |
|---|---|---|---|
| Cache miss (real provider call) | 15 | 902 ms | 2709 ms |
| Cache hit (Postgres lookup) | 45 | 9 ms | 10 ms |
In this one run, a hit took 9 ms at the median and a miss 902 ms. The hit's p95 (10 ms) is close to its median, which fits a single indexed lookup. The miss's tail comes from the provider. Because the gateway's host was not recorded, the 9 ms says how fast a lookup was here, not how fast it will be on your setup.
The cost gap
A hit also skips the bill. Its x-gateway-cost-usd header reads 0, and the
gateway's ledger records cache_hit rows at zero cost without opening a
spend-tracking transaction:
| calls | total cost | |
|---|---|---|
| Misses (real spend) | 15 | $0.000063 |
| Hits (what they would have cost at the average cost of a miss) | 45 | $0.000189 |
| Actual spend, this run | 60 | $0.000063 |
At this run's 3-in-4 duplicate rate, caching cut spend by 75%, which is the
duplicate share of the traffic (45 of 60 calls were repeats). The dollar amounts
are tiny because gpt-4o-mini is cheap and the test used 5-token replies, so the
ratio is the number to carry over. Where a share of your calls repeat exactly, such
as a support bot answering the same few questions or a batch job that re-processes
overlapping input, that share is your cost reduction, whatever your per-call price.
What actually gets cached
The cache key is a hash of model, messages (in order), temperature,
max_tokens, top_p, stop, response_format, tools, tool_choice and,
when set, reasoning_effort. A call that differs in any one of these is a
separate cache entry. Because the whole message list is in the key, a hit needs
the exact same conversation. For a long system prompt that repeats with different
user messages, use the provider's prompt caching, which the gateway passes through.
A few specifics worth knowing before you rely on it:
temperaturemust be explicitly0. An omitted temperature is never cached, on purpose. If you did not set the temperature, the gateway assumes you want a fresh sample, not a stored answer.- Streaming calls are never cached. A streamed request is never looked up in the cache, and its reply is never stored.
- The cache is per-team. Two teams sending the identical request get two separate entries; nothing about a hit is shared across tenants.
- A hit is still traced. It writes the same span a miss would, tagged so you can tell them apart, with the real token counts. Only the cost is zero, and no provider is called.
Key point: An exact-match cache pays off only for traffic that repeats word for word, with pinned sampling settings. The saving equals the share of calls that repeat.
Which kind of cache to use
Three kinds of caching come up for LLM calls. This post measured only the first.

| Cache | What must match | What you save | Risk |
|---|---|---|---|
| Exact-match response cache (this gateway) | The whole request: model, every message, sampling settings, tools | The whole call: no provider call, $0 | None for the same request at temperature: 0; an answer can go stale within the cache window |
| Provider prompt caching | A repeated prefix, such as a long system prompt | Part of the input cost; the model still runs | The reply is always fresh |
| Semantic cache | A request with a similar meaning, by embedding similarity | The whole call | A similar but different question can get the wrong stored answer |
The AcruxCore gateway has the first kind and passes the second through to the provider. It has no semantic cache.
What this means for you
- Turn it on for a virtual key that serves repeat traffic. The saving grows with how often the exact same request comes back, not with volume alone.
- Set
temperature: 0if you want caching. The gateway stores nothing without it. - The cost saving equals your duplicate rate, not a fixed percentage. This run's 75% came from sending each prompt four times, and a lower repeat rate saves proportionally less.
The numbers above come from one live run of gateway-cache-bench.mjs: 15 fixed
prompts, 4 passes each, on a virtual key with cacheTtlSeconds set. The script
reads the x-gateway-cache and x-gateway-cost-usd response headers, so a hit
or a miss is not guessed from latency.
FAQ
What is an exact-match LLM cache?
It stores a model's reply and returns it when the exact same request comes back.
In the AcruxCore gateway, the key covers the model, the messages in order, the
sampling settings, tools, tool_choice and response_format.
How much faster is a cache hit?
In our one run, a hit took a median of 9 ms and a call to the provider 902 ms. The gateway's host was not recorded, so treat the 9 ms as one measurement.
How much does LLM response caching save?
The saving equals the share of calls that repeat exactly. In our test, 3 of every 4 calls repeated and spend fell by 75%.
Does temperature affect caching?
Yes. The AcruxCore gateway caches a call only when temperature is explicitly
0, and an omitted temperature is never cached.
Are streamed calls cached?
No. A streamed request is never looked up in the cache, and its reply is never stored.
What is the difference between exact-match and semantic caching?
An exact-match cache returns a stored reply only for the identical request. A semantic cache also returns one for a request with a similar meaning, which can give a wrong answer to a different question. The AcruxCore gateway has no semantic cache.
gateway-cache-bench.mjs — the cache benchmark.