← Back to blog

Anthropic Cache TTL: 5min vs 1hr Cost Breakdown (2026)

Synrouter Team4 min read
anthropicprompt-cachingcache-ttlclaude-codecost-optimization

Anthropic's prompt caching cuts input costs by 90%. The catch nobody mentions: the default cache expires in 5 minutes.

If your Claude Code session pauses for a coffee, a code review, or a CI run — anything longer than 5 minutes — the cache evaporates. The next request re-reads the entire context at full price. Then it writes a new cache entry. You pay for the re-read and the re-write.

There's a 1-hour alternative. It costs more to write but survives the gaps. We ran the numbers.

The Two TTL Options

Anthropic's prompt caching supports two TTL values:

TTLCache Write Cost (Sonnet 4.6)Cache Read CostHow to Enable
5 minutes (default)$3.75/M$0.30/MAutomatic with cache_control
1 hour (extended)$6.00/M$0.30/Mttl: "1h" + beta header

Cache reads cost the same regardless of TTL — $0.30/M on Sonnet, one-tenth the standard $3/M input rate. The difference is in the write cost: the 1-hour cache is 60% more expensive to write.

That sounds like a bad deal until you account for cache expiration.

The Expiration Problem

A typical Claude Code session isn't a tight request loop. It looks like this:

TimeActivityGap to Next Request
0:00Agent generates code2 min (reading output)
0:02Agent refactors4 min (reviewing diff)
0:06Agent writes tests8 min (running test suite)
0:14Agent fixes failing test3 min (reading error)
0:17Agent commits12 min (reviewing PR, getting coffee)

Three of those gaps exceed 5 minutes. Each time, the cache expires. The next request pays full $3/M input on the entire context — system prompt, tool definitions, conversation history — then writes a new cache at $3.75/M.

With the 1-hour TTL, those gaps don't matter. The cache survives. You pay the higher write cost once, then read at $0.30/M for the rest of the session.

Real Cost Comparison

We modeled a 50-turn Claude Code session on Sonnet 4.6 with a 15K-token system prompt, growing conversation history, and 5K new tokens per turn. We assumed 15% of turns have a gap exceeding 5 minutes (the 5-min scenario) vs 2% exceeding 1 hour (the 1-hour scenario).

Metric5-min TTL1-hour TTL
Cache hit rate73.3%99.1%
Uncached input0.25M ($0.75)0.25M ($0.75)
Cached reads1.27M ($0.38)1.72M ($0.51)
Cache writes0.46M ($1.73)0.01M ($0.09)
Output0.03M ($0.38)0.03M ($0.38)
Session total$3.24$1.73

The 1-hour TTL saves $1.51 per session — a 47% reduction. The savings come almost entirely from eliminating cache re-writes. The 5-minute TTL spends $1.73 on cache writes because the cache keeps expiring and being recreated. The 1-hour TTL spends $0.09 because it writes once and reads for the rest of the session.

Scaled to a team running 5 sessions/day:

Period5-min TTL1-hour TTLSavings
Daily$16.20$8.65$7.55
Monthly$324$173$151

When to Use Which

Use the 5-minute TTL when: your workload is a tight request loop with no gaps. Interactive chat, rapid-fire API calls, CI pipelines that fire requests back-to-back. The cheaper write cost wins because the cache never expires.

Use the 1-hour TTL when: you're running agent sessions with natural pauses. Claude Code, Codex CLI, any workflow where the agent waits for human input, test results, or CI. The higher write cost is recovered within 2-3 cache reads.

The problem: Claude Code uses the 5-minute TTL by default and doesn't expose a setting to change it. You'd need to route requests through a proxy that adds the ttl: "1h" cache_control parameter and the extended-cache-ttl-2025-04-11 beta header.

How to Enable the 1-Hour TTL

If you're calling the Anthropic API directly:

python
1response = client.messages.create(
2 model="claude-sonnet-4-6-20250514",
3 messages=[{
4 "role": "user",
5 "content": [
6 {"type": "text", "text": "cacheable prefix", "cache_control": {"type": "ephemeral", "ttl": "1h"}},
7 {"type": "text", "text": "user message"}
8 ]
9 }],
10 extra_headers={"anthropic-beta": "extended-cache-ttl-2025-04-11"}
11)

If you're using Claude Code, you can't set this directly. The agent manages its own cache_control headers. A gateway like Synrouter can intercept requests and upgrade the TTL automatically — which is what we do.

We hit this problem ourselves. Sessions with debugging pauses were costing 40-50% more than they should have, purely from cache expiration. We built the TTL upgrade into the gateway because it was the only way to fix it without modifying Claude Code itself.

If your agent sessions have natural pauses and your cache hit rate is below 80%, the TTL is probably why. Sign up to get started — Synrouter upgrades cache TTLs automatically, no code changes required.

Read next: The Hidden Cost of Claude's Prompt Caching: Why Your Agent Is Bleeding Tokens

FAQ

What is Anthropic's prompt caching TTL?

Anthropic offers two cache TTL options: the default 5-minute ephemeral cache and an extended 1-hour cache. The 5-minute TTL is the default and requires no special configuration. The 1-hour TTL requires passing ttl: '1h' in the cache_control block and uses the extended-cache-ttl-2025-04-11 beta header.

How much does the 1-hour cache TTL cost?

The 1-hour cache write costs more than the 5-minute write. On Sonnet 4.6, a 5-minute cache write costs $3.75/M tokens while a 1-hour cache write costs $6.00/M tokens. Cache reads cost the same either way: $0.30/M on Sonnet.

When should I use the 1-hour cache TTL?

Use the 1-hour TTL for long-running agent sessions where gaps between requests exceed 5 minutes — debugging, code review, waiting for CI. If your requests are always under 5 minutes apart, the 5-minute TTL is cheaper because cache writes cost less.

Does Claude Code use 5-minute or 1-hour cache TTL?

Claude Code uses the default 5-minute TTL. If your session has gaps longer than 5 minutes (reading docs, running tests, reviewing PRs), the cache expires and subsequent requests pay full input price until a new cache entry is written.