Brief in AI engineering
Prompt caching rules
States what each model vendor's prompt cache stores, its smallest prompt, its lifetime and what breaks it.
- Changed 4 Dec 2026
- Sources read 4 Dec 2026
- 4 sources
- Version 1
- About 1,350 tokens
- Needed by both models tested, 4 Dec 2026
Anthropic caches only when asked (cache_control), with 5-minute or 1-hour entries. OpenAI caches automatically; from GPT-5.6 it adds explicit breakpoints and 30-minute or 12-hour lifetimes. Google caches implicitly on Gemini 2.5 and newer; Gemini 4 has no explicit caches.
Facts
| Item | Anthropic | OpenAI (GPT-5.6 and later) | Google Gemini |
|---|---|---|---|
| Switch | cache_control, at top level (automatic) or on blocks [1] |
prompt_cache_options.mode: implicit or explicit [2] |
Implicit, on by default for Gemini 2.5 and newer [3] |
| Cache writes per request | Up to 4 breakpoints [1] | Up to 4 cache writes [2] | No breakpoints; prefix matched from the first token [3] |
| Default lifetime | 5 minutes [1] | 30 minutes ("30m") [2] |
Best effort, up to 24 hours in memory [3] |
| Longer lifetime | "ttl": "1h" [1] |
"12h", Responses API only [2] |
Gemini 4: evicted prefixes may stay on SSD up to 12 hours from creation [3] |
- Anthropic smallest prompt: 512 tokens on Claude Opus 5.5, Sonnet 5.5, Haiku 5.5, Opus 5, Fable and Mythos 5.x [1].
- Anthropic smallest prompt: 1,024 tokens on Opus 4.8, Sonnet 5, Sonnet 4.6 [1].
- Anthropic smallest prompt: 2,048 tokens on Opus 4.7, Mythos Preview [1].
- Anthropic smallest prompt: 4,096 tokens on Opus 4.6, Opus 4.5, Haiku 4.5 [1].
- OpenAI smallest prompt: 1,024 visible tokens on GPT-5.6 and later; hidden system tokens do not count [2].
- Google smallest prompt: 4,096 tokens on Gemini 4 and Gemini 3 [3].
- Google smallest prompt: 2,048 tokens on Gemini 2.5 [3].
- Anthropic: a prompt below the minimum is processed uncached, and no error is returned [1].
- Anthropic: each cache hit refreshes the lifetime, counted from the start of the request [1].
- Anthropic: each breakpoint looks back at most 20 blocks for an earlier write [1].
- Anthropic: a 1-hour entry must come before any 5-minute entry in the same request [1].
- Anthropic: thinking blocks, citation sub-blocks and empty text blocks cannot carry
cache_control[1]. - Anthropic: changing tool definitions invalidates the whole cache [1].
- Anthropic: toggling web search, citations or fast speed invalidates the system and message caches [1].
- Anthropic: changing
tool_choice, images or thinking settings invalidates the message cache; changing effort can too [1]. - Anthropic: a
{"role": "system"}message added mid-conversation keeps the cache; Claude Sonnet 5 does not support it [1]. - OpenAI: the implicit breakpoint uses one of the 4 cache-write slots [2].
- OpenAI: explicit mode without any
prompt_cache_breakpointcaches nothing [2]. - OpenAI:
prompt_cache_options.prewarm: truefills the cache without generating output [2]. - OpenAI: from GPT-6.2, top-level
instructionssit afterinputand are always billed uncached [2]. - OpenAI:
prompt_cache_keysteers routing before GPT-5.6; from GPT-5.6 it only separates cache accounting [2]. - OpenAI: before GPT-5.6,
prompt_cache_retentionisin_memory(5 to 10 minutes idle, up to 1 hour) or24h[2]. - OpenAI: before GPT-5.6, the default is
24hwithout Zero Data Retention andin_memorywith it; GPT-5.5 accepts only24h[2]. - Google: Gemini 4 order is
thinking_level, built-in tools, function declarations,system_instruction, then turns [3]. - Google: changing
thinking_levelon Gemini 4 breaks the whole cache [3]. - Google: on Gemini 4, every request recomputes a trailing 2,050-token window uncached [3].
- Google: explicit
cachedContentsexist only on Gemini 3 and Gemini 2.5 throughgenerateContent[4]. - Google: an explicit cache's TTL defaults to 1 hour, with no minimum or maximum [4].
Use it for
- Choosing where to put breakpoints and volatile content so the cached prefix stays identical.
- Checking whether a prompt is long enough to cache on a model.
- Choosing a lifetime that covers the gap between requests.
- Not for costs: cache read and write prices are in data/llm-models.
Sources
- [1] Prompt caching (prompt-caching), Anthropicread 4 Dec 2026
- [2] Prompt caching, OpenAIread 4 Dec 2026
- [3] Context caching, Googleread 4 Dec 2026
- [4] Context caching (GenerateContent API), Googleread 4 Dec 2026
Tested
Tested 4 Dec 2026: claude-haiku-5-5 stated 9 of its 32 facts without this page and 32 with it; claude-fable-5-2 stated 8 of its 32 facts without this page and 32 with it.
Changes
- Opened on mysi.4 Dec 2026
Cite as: mysi, Prompt caching rules, mysi.dev/prompt-caching-rules, version 1, changed 2026-12-04. Text and data CC BY 4.0.