Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4133 pages

AI for developers

Prompt Caching TTL: How Long OpenAI, Claude and Gemini Keep Your Prefix

In short

The prompt caching TTL differs by API. Claude keeps an entry 5 minutes and extends it on every read, OpenAI's newest models keep one at least 30 minutes, and Gemini's explicit caches last 1 hour unless you set another TTL. A miss usually comes from a changed prefix or a prompt below the minimum size, not from the clock alone.

What is the prompt caching TTL of each API?

A cache that lapses between two requests turns the second one back into a full-price, full-latency call, so the lifetime is the first number to check. The three vendors define it in three different ways, which is why a single value for all of them would mislead.

APIDefault lifetimeLonger optionWhat extends it
Claude5 minutes1 hour, set with ttl 1h in cache_controlEach use of the cached content refreshes it at no extra cost
OpenAI, GPT-5.6 and later30 minutes as a minimum12 hours as a minimum, Responses API onlyA 30-minute read extends coverage to at least 30 minutes after the read; it does not restart a 12-hour clock
OpenAI, earlier modelsin_memory: about 5 to 10 minutes of inactivity, up to one hour24h retention: typically around 30 minutes, up to 24 hoursDepends on the model and on your organisation's retention policy
Gemini, explicit cache1 hour when you set no TTLAny ttl or expire_time you chooseYou update ttl or expire_time yourself; nothing else about a cache can be edited
Gemini, implicit cacheThe caching page states no lifetimeNone offeredThe zero-data-retention page says implicit data sits in RAM with a 24-hour TTL

Checked against: source 1, source 2, source 3, source 5

Does a longer TTL mean the entry is deleted on schedule?

Not on OpenAI. The guide describes the 30-minute and 12-hour values as minimum lifetimes and adds that entries may stay longer than requested, so 12 hours is not a deletion deadline. Treat the number as the time you can count on a discount, not the time the data disappears.

Claude is the stricter one for planning. Its guide measures the lifetime from the start of the request that wrote or read the entry, not from the end of the response. A response that streams for four minutes leaves roughly one minute of a five-minute entry for the next request to use.

Checked against: source 2, source 1

What is the smallest prompt each vendor will cache?

Marking a block for caching does nothing when the prefix is under the cut-off. Claude's cut-off depends on the model: 512 tokens for the newest Opus, Sonnet and Haiku generation, 1,024 for a middle group, 2,048 for Opus 4.7 and 4,096 for Opus 4.6 and 4.5. Shorter prompts run normally and are simply not cached.

OpenAI sets 1,024 tokens for GPT-5.6 and later and says earlier models vary with request settings. The hidden system content OpenAI adds does not count toward that minimum.

Gemini lists 4,096 input tokens for its current model families and 2,048 for Gemini 2.5 Pro. For Gemini 4 agent loops there is a second rule: the whole previous request is cached only if the new request adds at least 2,050 tokens, otherwise the last 2,050 tokens are processed again at the standard input rate.

Checked against: source 1, source 2, source 3

Why does a cache miss when the TTL has not run out?

On Claude the hit needs a prefix that is identical to the stored one, text and images included, up to the breakpoint. Changing tool definitions invalidates everything. Switching web search, citations or the speed setting invalidates the system and message levels. Changing tool_choice or adding or removing images invalidates only the message blocks.

Claude also looks back only 20 blocks from a breakpoint for an entry an earlier request wrote. In a conversation that adds more than 20 blocks per turn, a single breakpoint at the end finds nothing, and a second breakpoint further back is needed. Up to four breakpoints are allowed, and an automatic breakpoint uses one of those slots.

OpenAI reports cached_tokens after subtracting its hidden system tokens and rounding down to a multiple of 128, so a hit can look smaller than the prefix you sent.

Checked against: source 1, source 2

Who decides where the cache boundary goes?

Claude offers both modes. A top-level cache_control moves a breakpoint to the last cacheable block automatically, and explicit cache_control on individual blocks gives fine control. Mixing a different TTL on the last block with automatic caching returns a 400 error.

OpenAI's prompt_cache_options.mode is implicit or explicit. In implicit mode it places a breakpoint at the end of the latest eligible message, and in explicit mode a request without breakpoints does no caching at all.

Gemini splits the choice by generation. Implicit caching is on by default for Gemini 2.5 and newer. Explicit cache objects work on Gemini 3 and 2.5 and are not supported on Gemini 4, which relies on implicit caching only. The explicit feature is marked Beta.

Checked against: source 1, source 2, source 3, source 4

Where is the cached data kept, and who can reach it?

Claude isolates caches between organisations, and between workspaces on the Claude API, Claude Platform on AWS and Microsoft Foundry. On Amazon Bedrock and on Claude models on Google Cloud the isolation is by organisation only.

OpenAI says caching may store encrypted key and value tensors in GPU-local storage. For models that support both retention modes, an organisation without zero data retention defaults to 24h, and one with it defaults to in_memory. The guide also warns that traffic above 15 requests a minute can overflow to other machines.

Google describes Gemini's implicit cache as RAM only and isolated per project, and says that does not breach zero data retention. Explicit caches are the part to avoid if a zero-footprint setup is the goal.

Checked against: source 1, source 2, source 5

Which setting should you check first?

Start from the gap between your requests, not from the vendor. If traffic arrives every few minutes, Claude's default entry survives on its own because every read refreshes it. If the gaps are half an hour or longer, look at Claude's 1-hour option, OpenAI's 12-hour minimum or a Gemini explicit cache with a TTL you set.

Checked against: source 1, source 2, source 3

What else do people ask?

Does reading a cache entry extend its life on every API?

Only Claude states it that plainly: each use of cached content refreshes the 5-minute lifetime. OpenAI describes extended coverage for newer models and minimum lifetimes, and Gemini's explicit caches change only when you update ttl or expire_time.

Can I check whether a request hit the cache?

Yes. OpenAI reports cached_tokens and cache_write_tokens in the usage block, Claude returns cache read and write figures in usage, and Gemini shows cached token counts in its response metadata.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. This page compares the three vendors' documentation, which I read on 20 Nov 2026. I did not send requests to any of the three APIs for it, so it reports documented behaviour, not measured behaviour. It leaves out prices, hit-rate or latency figures, and cloud-provider hosted variants other than the isolation notes. Found a mistake? Tell me.

Keep reading

Next step

Have a project in mind?

Tell me about it. A discovery call within 48 hours.