Gemini prompt caching: implicit vs explicit, and the storage cost
Gemini offers both implicit and explicit caching. Explicit caches are a real product with their own price, so an oversized or short-lived cache can cost more than it saves.
The numbers
| Value | |
|---|---|
| Base input price | $1.25 / MTok |
| Cache read | 0.1× base → $0.13 / MTok |
| Cache write | 1× base → $1.25 / MTok |
| Minimum cacheable prefix | 2,048 tokens |
| Breakeven | 0.00 reads per cached write |
Cache writes are free here (1× base), so there is no write premium to recoup — a cache hit is pure saving from the first read. The failure mode on this provider is not breakeven, it is a prefix that never stabilises, so the cache never engages at all.
Explicit caches are billed for storage
An explicit cache is charged per hour of storage in addition to the discounted read rate. A cache that is written once and read twice can lose money against just paying full price — model the reuse count before you create one.
What breaks the cache
Caching is an exact-prefix match. The first changed byte invalidates everything after it, and no provider raises an error. In 236 production system prompts:
- 76 (32.2%) rendered a date or time inside the cached prefix
- 68 (28.8%) were below the minimum cacheable length
- 36 (15.3%) carried a prefix far larger than it needed to be
- 27 (11.4%) kept mutable working memory inside the prefix
The fix
Order the request so the cached span is byte-identical on every call:
static system instructions ← cached tool definitions ← cached, breakpoint here --- cache breakpoint --- volatile context, dates, IDs ← after the breakpoint user message ← never cached
Content after the breakpoint costs only its own write. The same content before it invalidates everything downstream. Same bytes, different order, completely different bill.
Check your own prompt
Paste a system prompt or a raw API request. Get a score, the offending lines, and a modelled monthly cost. Runs in your browser — no API keys, no account, nothing leaves the page.
Run the audit →Or gate it in CI: npx prefix-audit prompts/ --provider gemini