Foreverse Research · Data report

Prefix caching,
and what your chats really cost

Same 15-round roleplay chat, same model, same API key, byte-identical messages: $0.0241 in bare SillyTavern, $0.0664 in our own app before the fix — 2.8×. The difference bought almost nothing. Every extra cent went to re-sent history that never got the repeat-prefix discount. This report opens that bill: what the discount is, who actually gets it, what kills it, and how to audit your own setup.

Benchmark data: 2026-07-23 to 07-24 · Price snapshot: 2026-07-24 · Published: 2026-07-26

The one-minute version

  1. Major providers automatically discount the part of a request that is byte-identical to the previous one, from the first byte on: DeepSeek bills cache hits at 2% of full input price; Anthropic, OpenAI and Google sit around 10%; xAI, Zhipu and Qwen at 15-20% (list prices, 2026-07-24). No sign-up; the only requirement is a byte-stable beginning.
  2. Hit rate is client behavior, not luck: same model, same key, byte-identical scripts. Stock SillyTavern hits 91.5% out of the box; we measured 46.5% before our fix. Same 15-round chat, 2.8× the money (July 2026 four-way benchmark; 89.9% after the fix, shipped).
  3. Inside one app, card structure alone spreads hit rates threefold: a card whose lorebook is all keyword-triggered measured 22.6%; one with two always-on entries measured 74.3% (pre-fix). Your card is quietly deciding your bill.
  4. Extrapolated to 100 rounds on the same formula: the 46.5% setup pays $0.20 per session, the 89.9% setup $0.054 (DeepSeek V4 Flash). The longer the history, the wider the gap: 2.8× measured at 15 rounds grows to 3.8× at 100.
  5. Only one kind of action kills the cache: changing the beginning of the request. Four measured cases: lore injection drift, dynamic lines routed through a system role that gets merged to the top, plugin floods and mid-history injection, and sliding-window truncation once the context fills.
  6. Output tokens never get the discount. The pricier a model's output, the less caching can save: fixing the hit rate from 46.5% to 89.9% cuts a DeepSeek bill by 74%, but a Claude Sonnet 4.6 bill by only 60%, because most of its money sits in $15/M output.

What prefix caching is, and how deep the discount runs

Prefix caching (prompt caching) is an automatic provider discount: the part of this request that is byte-identical to the previous one, starting from the very first byte, bills at the cache-read price instead of full price. DeepSeek's cache-read is 2% of full input; Anthropic, OpenAI and Google are around 10%. Nothing to apply for, nothing to code; the response's usage field reports how much was hit.

Roleplay and long-form chat are the biggest beneficiaries because every turn re-sends the entire history: by round 100, the previous 99 rounds are all “repeated prefix”, so in theory well over 90% of billed input tokens should ride the discount. A five-round Q&A barely notices it. Caching decides long-chat bills, not short ones.

Cache-read prices for twelve common models (list-price snapshot 2026-07-24)

ModelProviderFull input $/M tokensCache read $/M tokensHit price vs full
DeepSeek V4 FlashDeepSeek$0.14$0.00282.0%
DeepSeek V4 ProDeepSeek$0.435$0.0036250.8%
Claude Sonnet 4.6Anthropic$3$0.310.0%
Claude Opus 4.8Anthropic$5$0.510.0%
GPT-5.6OpenAI$5$0.510.0%
Gemini 3.1 Pro PreviewGoogle Gemini$2$0.210.0%
Gemini 3.5 FlashGoogle Gemini$1.5$0.1510.0%
Kimi K3Moonshot Kimi (intl)$3$0.310.0%
Grok 4.5xAI Grok$2$0.315.0%
GLM-5.2Zhipu GLM$1.4$0.2618.6%
Qwen3.7 MaxAlibaba Bailian (intl)$2.5$0.520.0%
MiniMax-M3MiniMax$0.3$0.0620.0%

Providers' own pages are authoritative; this is a models.dev snapshot. Some providers charge extra for cache writes, and cache lifetimes range from minutes to hours; neither is modeled here (see Honest limits).

Tiers within one provider differ too (DeepSeek V4 Pro's hit price is 0.8% of full). Check this column before switching models; it decides how much fixing your cache is worth on your bill.

Four bills for the same chat: the instrumented benchmark

In July 2026 we ran a four-way benchmark: bare SillyTavern (v1.18.0 stock), fully-modded SillyTavern (the community's most popular preset + plugin stack), Foreverse standard, and Foreverse Smart Play — same model (deepseek-v4-flash), same key, byte-identical 15-round scripts, every call metered through one gateway. The first defect it caught was ours.

Cache hits and cost (15-round sessions, 3 cards × 3 repeats)

Bare SillyTavernFully-modded STForeverse standardForeverse Smart Play
Cache hit rate · pre-fix (2026-07-23)91.5%74.6%46.5%42.3%
Cache hit rate · post-fix (2026-07-24)89.9%88.3%
Total cost, 9 cells · pre-fix$0.0241$0.0676$0.0664$0.0898
Total cost, 9 cells · post-fix$0.0278$0.0328
Prompt volume (vs bare ST)2.46×1.16×1.59×
Empty upstream replies (still billed)0/13512/135 (8.9%)0/1350/142

Foreverse standard sent only 16% more prompt volume than bare ST yet paid 2.8× the money. Almost the entire gap is hit rate: at DeepSeek prices a miss costs 50× a hit, so hit-rate differences convert directly into cash.

46.5% is the number this benchmark caught in our own app; we keep it on the record. The root cause (lore injection position drifting every turn) was traced the same night; the fix shipped in a release build, re-verified at 89.9%, matching stock ST, with 58-63% lower cost.

One app, three cards, a threefold spread (pre-fix, standard mode)

Card's lorebook structureCache hit rate
10 entries, all keyword-triggered (original-world card)22.6%
12 entries, all keyword-triggered (folklore card)27.7%
2 always-on + 5 triggered (modern slice-of-life card)74.3%

Same pipeline, same build, same device; the only structural difference is that always-on entries keep the request head constant. Triggered entries drift in and out each turn, invalidating every byte after the insertion point. After the injection-layer fix, the three-card spread collapsed from 51.7 points to 5.8.

Per-turn hit curve, before vs after the fix (same card, same 15-round script, %)

Turn123456789101112131415
Pre-fix (27.7%)009114131514111312121194873
Post-fix (89.9%)989493929419939496949593959595

The one dip after the fix (turn 6, 19%) is a new lore entry entering the prompt for the first time: a first-entry miss is a one-time design cost, not a disease. Read the shape, not single points: sawtooth everywhere means something is broken; an isolated dip followed by quick recovery is normal metabolism.

What 100 rounds cost at each hit rate

Plugging the measured hit rates into the exact formula our calculator uses (a 2,000-token card-plus-system prefix, 120 tokens in and 350 out per round, DeepSeek V4 Flash at 2026-07-24 list prices) gives the following input-plus-output totals for a 100-round chat. This is a same-formula extrapolation, not a measurement; the measured data is the 15-round set above.

Hit rateWho lives here100-round totalvs best
0%All-miss control$0.3657.6×
46.5%Us, pre-fix$0.2044.2×
73.1%Upgraded install$0.1122.3×
89.9%Fresh install, post-fix$0.0541.1×
91.5%Stock SillyTavern$0.0481.0×

A single 100-round session on a budget model is small change; the point is the ratio. This tax is levied on every session, and the rate climbs with length: 2.8× measured at 15 rounds becomes 3.8× at 100, because history dominates more of each request.

Pricier models scale the amounts up proportionally; the structure doesn't change. Our official channel adds a 50% service margin on list prices; both lines scale together, the saving rate stays the same.

One bill line people miss: output tokens always bill at full price; caching only covers input. So the pricier a model's output, the less caching can rescue. The same 100 rounds on Claude Sonnet 4.6 ($15/M output): $4.97 at the 46.5% tier, $2.01 at 89.9%: the same hit-rate repair cuts the bill by only 60% (vs 74% on DeepSeek), because most of the money sits in output. On expensive-output models, trimming reply length pays off before cache repair does.

What kills your cache: four measured cases

Prefix caching has exactly one failure condition: the beginning of the request changed. All four cases below come from our own measurements; three of them happened in our own product, with numbers from before and after the fix.

Case 1 · Lore injection drift (the root of our 46.5%)

A keyword-triggered lorebook activates a different entry set every turn: this round “lighthouse”, next round “brass whistle”. The injected block changes, and every byte after the insertion point is recomputed at full price. The evidence is the three-card spread above: 74.3% for the card whose always-on entries keep the head stable, 22.6% for the all-triggered card. Same app, threefold difference.

The fix was two moves: make once-activated entries resident for the session, and pin the injection position. Re-verified at 89.9% versus 27.7% before, level with stock SillyTavern. Which deserves its own sentence: bare ST's 91.5% comes from a prompt structure that is naturally stable when nothing is installed. We fixed our app by aligning with it, not by beating it.

Case 2 · The system message you put at the end is actually at the top (the 53% and 58% cases)

DeepSeek's chat template merges every system message in the conversation to the very top. We verified this with production probes: a system block placed at the end of the messages and one placed at the head produce identical hit rates (97%). So a per-turn line like “it is now 14:32” routed through the system role rewrites the first screen of the prompt every single turn — and the entire history misses.

Two of our product chains stepped on exactly this: companion chat measured a 53% steady-state hit rate, character texting 58%. After moving dynamic content next to the latest user message and keeping only constant rules at the head: 97% and 96-98%. The gap grows linearly with history length: under the old layout, thirty rounds of history were recomputed at full price every turn.

Case 3 · The plugin tax, and mid-history injection (the 74.6% and 39.8% cases)

Fully-modded SillyTavern's 74.6% hit rate and 2.46× prompt volume are the two components of the plugin tax: popular presets and plugins push changing content into every turn: more volume, broken discount, 2.8× the total cost of bare ST, plus 12 of 135 rounds billed for empty upstream replies. That's the cost of the configuration stack, not a flaw in SillyTavern itself.

A steeper example: giving bare SillyTavern dice capability (author's-note mid-depth injection plus a tools array) dropped it from 91.5% to 39.8%. Depth injection, per-turn retrieval and rolling summaries all belong to the same family of mid-history inserts. Serious plugin authors in the English ecosystem already warn in their own READMEs that rolling injection voids your prompt cache. The people writing these plugins know the bill.

Case 4 · Context full: sliding-window truncation is structural death

Once the context window fills, the client starts dropping old messages from the top — the beginning now moves every turn, and no configuration survives it. In our 300-round long-chat special, all four setups shattered: bare ST fell from 91.5% (short sessions) to 14.4%; modded ST held 41.6% on the back of a giant fixed prefix; our standard mode 4.9%, Smart Play 19.0%.

The way out isn't “don't chat that long”. It's compaction: pin the seam between summary and raw history, so everything between two seams stays byte-stable. Our long-chat compaction works in this direction, with an honest cost attached: every time the seam advances, one round of recompute is due, so the dividend shrinks while compaction is actively advancing.

Self-audit: six cache-killing habits

Each item gives the symptom, how to check, and what to do. The first four audit your own configuration; the last two audit your provider and your session length. Step zero is always getting the real hit number: it's in the response's usage field, and what you can't measure you can't fix.

  1. Your lorebook is almost all keyword-triggered, with no always-on entries. Check: Chat a dozen rounds on one card and watch the per-turn hit rate; sawtooth everywhere is the tell (our measurements: 22.6% all-triggered vs 74.3% with always-on entries). Do: Make core entries always-on (constant/“blue light” in SillyTavern), or use a client that keeps once-activated entries resident.
  2. Timestamps, status bars, or any per-turn content live in the system prompt or the head. Check: Export two consecutive request bodies and diff the first screen. Some chat templates merge all system messages to the top, so “written at the end” does not mean “effective at the end”. Do: Move dynamic content next to the latest user message; keep the head constant. Our two chains went from 53%/58% steady-state to 96%+ with exactly this change.
  3. You run mechanisms that insert into the middle of history: depth injection, mid-depth author's notes, per-turn vector retrieval, rolling summaries. Check: Read the plugin's docs for any mention of caching (serious ones warn you); otherwise compare hit rates with it on and off (bare ST with dice config: 91.5% → 39.8%). Do: Set injection depth to the tail if the option exists; if not, accept the tax knowingly — and don't stack a second mechanism from the same family.
  4. You frequently edit, delete, or reorder old messages. Check: Nothing to check; the behavior is the answer: everything after the edit point is invalidated. Do: Nothing to fix. It's a fair price for a real feature; just know the next turn after an edit will fully miss, and don't sweat single-turn dips.
  5. Your provider or relay doesn't report hit numbers. Check: Look for cached_tokens, cache_read, or prompt_cache_hit_tokens in the response usage; if none exist, you're flying blind. Do: Switch to a direct connection or a channel that reports hits. We've measured a relay pool where byte-identical requests never hit across turns; when the pool isn't sticky, the discount simply never arrives.
  6. Deep into a long chat, the hit rate falls off a cliff and never recovers. Check: Check whether session tokens are approaching the model's context limit; once full, the client starts sliding-window truncation and the head moves every turn. Do: Turn on summarization or compaction yourself instead of letting truncation cut history for you: truncation is a moving head every turn; seam-pinned compaction at least restores a stable prefix between seams.

Tools, and where to go next

The division of labor in one line: the tools compute your numbers; this report explains why, and what to do.

Method and scope

  • Four-way hit rates and costs: the 2026-07-23/24 benchmark: same model (deepseek-v4-flash), same key, byte-identical 15-round scripts; 3 cards × 4 setups × 3 independent repeats = 36 cells (pre-fix baseline) plus an 18-cell post-fix comparison; every call metered through one transparent gateway, and a cell only counts after the gateway, the ST-side log and the app-side ledger agree. About 1,530 real calls, roughly $1.07 at list prices.
  • The two product-chain numbers (53%→97%, 58%→96-98%): production probes against DeepSeek direct, padded with 30 rounds of history, independent salts, two consistent re-runs (2026-07-14).
  • Discount table and 100-round bills: models.dev list-price snapshot of 2026-07-24; the simulation formula is identical to our calculator's (2,000-token prefix, 120 in + 350 out per round), with parameters stated in the text.
  • Cache hits are counted from provider usage fields (DeepSeek's prompt_cache_hit_tokens and friends), not estimated by us.
  • Everything is recomputable: per-call metering logs, per-cell transcripts and reconciliation records are archived behind the four-way benchmark page.

Honest limits

  • All measured hit rates come from a single model (deepseek-v4-flash) through one gateway. The discount table lists many providers' prices, but “how much you will hit” does not transfer across models: the failure mechanics are universal, the percentages are not.
  • The benchmark scenario is a 15-round fixed-script roleplay session, not a distribution of real-world usage. Your hit rate is decided by your card structure, plugins and editing habits, which is exactly why the self-audit list exists.
  • Costs are mechanical conversions at public list prices, for between-group comparison only, not a prediction of your bill. Cache-write fees and cache lifetimes (minutes to hours, provider-dependent) are not modeled.
  • The 100-round section is a same-formula extrapolation, not a measurement; the measured data is the 15-round set.
  • Our fix numbers come in two shapes: 89.9% measured on fresh installs, 73.1% on upgraded ones; closing that gap touches stored configs and is a separate product decision this page won't promise for.
  • Prices are a 2026-07-24 snapshot and will drift; providers' pages are authoritative. CNY figures use 1 USD ≈ 7.2 CNY.

How to cite this page

Foreverse Research, “Prefix Caching and What Your Chats Really Cost,” 2026-07. https://foreverse.app/research/cache-economics

FAQ

Where do I see my cache hit rate?

In the API response's usage field: DeepSeek reports prompt_cache_hit_tokens, Anthropic reports cache_read_input_tokens, and OpenAI-compatible endpoints commonly report prompt_tokens_details.cached_tokens. Foreverse shows the hit count per request in its API request log. If you can see none of these, fix observability first: what you can't measure you can't fix.

What's a healthy hit rate?

For 15-round roleplay sessions the measured ceiling sits around 88-92%: each turn's new reply and new input are structural misses, so nobody reaches 100%. Below 50% almost always means the setup is broken; walk the four cases. Isolated single-turn dips (a lore entry entering for the first time, or you edited history) are normal metabolism.

Does caching change reply quality?

No. Prefix caching reuses the intermediate computation of unchanged history; the model reads exactly the same content. What it changes is the bill and first-token latency: in the four-way benchmark, the setup with the highest hit rate also had the fastest first token (162ms vs 246ms).

Why doesn't my real bill match what the calculator says?

Most commonly: your real hit rate isn't the number you assumed. Hit rate is a function of client behavior, not luck: 46.5% and 91.5% are both measured values on the same model and script; the entire gap is setup behavior. Get your real hit number first (question one), then walk the self-audit list.

Prefix Caching and What Your Chats Really Cost — Measured Hit Rates, Real Bills (2026-07) · Foreverse · Xinmeng