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:
| TTL | Cache Write Cost (Sonnet 4.6) | Cache Read Cost | How to Enable |
|---|---|---|---|
| 5 minutes (default) | $3.75/M | $0.30/M | Automatic with cache_control |
| 1 hour (extended) | $6.00/M | $0.30/M | ttl: "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:
| Time | Activity | Gap to Next Request |
|---|---|---|
| 0:00 | Agent generates code | 2 min (reading output) |
| 0:02 | Agent refactors | 4 min (reviewing diff) |
| 0:06 | Agent writes tests | 8 min (running test suite) |
| 0:14 | Agent fixes failing test | 3 min (reading error) |
| 0:17 | Agent commits | 12 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).
| Metric | 5-min TTL | 1-hour TTL |
|---|---|---|
| Cache hit rate | 73.3% | 99.1% |
| Uncached input | 0.25M ($0.75) | 0.25M ($0.75) |
| Cached reads | 1.27M ($0.38) | 1.72M ($0.51) |
| Cache writes | 0.46M ($1.73) | 0.01M ($0.09) |
| Output | 0.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:
| Period | 5-min TTL | 1-hour TTL | Savings |
|---|---|---|---|
| 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:
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