CLAUDE LABJP
FORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as OctoberFORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as October
Articles/API & SDK
API & SDK/2026-05-29Advanced

Splitting Claude API prompt cache into 5m and 1h tiers — separate TTLs cut cost and stabilize ops

Anthropic's cache_control supports two TTLs: 5 minutes and 1 hour. Splitting them into a two-tier layout — 1h for static system/tools, 5m for variable few-shot — meaningfully changed both my costs and my on-call life. Here's the design with the numbers I observed.

claude-api81prompt-caching12cache-control2ttlcost-optimization28production111

Premium Article

The Messages API in the Anthropic SDK exposes a cache_control field that lets you ask the server to cache the prefix of a long prompt. I run Claude Lab as part of Dolice Labs (four sites I operate in parallel) and a handful of iOS / Android apps I have been shipping as an indie developer since 2014 (cumulative downloads passed 50 million along the way). Across all of that, the single biggest lever I have found for API cost is not "do you cache or not" but "how many TTLs do you use."

cache_control supports two TTLs: the default 5-minute ephemeral cache, and a 1-hour cache via ttl: "1h". I used to keep everything on 5m and assume that was fine. Six months ago I read the invoices line by line and realized I was leaving a lot on the table. The winning layout turned out to be 1h for static layers (system + tools) and 5m for variable layers (few-shot, RAG slices). This article is the engineering record of that change, with the actual numbers I saw.

Why a single TTL underperforms

My first prompt-cache layout looked like this:

# Before: a single 5m TTL for everything cacheable
response = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=2048,
    system=[
        {
            "type": "text",
            "text": SYSTEM_PROMPT,  # ~4,500 tokens
            "cache_control": {"type": "ephemeral"},  # 5m
        }
    ],
    tools=TOOLS,        # ~1,200 tokens
    messages=[
        {"role": "user", "content": user_text},
    ],
)

Cache hits started appearing in usage.cache_read_input_tokens, so it looked like things were working. Two real problems took weeks of logs to surface.

First, every time traffic went quiet for more than five minutes — which happened a lot at night and on weekends — the full 4,500-token system prompt was re-written and re-billed at the write rate. The write rate is 1.25x the normal input rate for 5m TTL, so dozens of cold-starts per day quietly ate most of my cache savings.

Second, when I tried to add a variable few-shot block at the end of the prompt, my fixed prefix kept getting invalidated. That was my own misunderstanding of where to put the breakpoint, but the two-tier layout described below removes the temptation entirely.

When 1h TTL is actually worth it

Passing ttl: "1h" extends the cache window to one hour, but the write cost roughly doubles versus the 5m option. If you apply 1h indiscriminately, your bill goes up, not down.

The rule I use is simple:

write-cost increase  <  hit savings
↓
mean inter-request gap  <  1h, with no extended idle windows
↓
1h TTL is worth it

For variable content — per-user few-shot, just-fetched RAG passages — 1h is meaningless. That content does not survive an hour and does not need to. Keep those layers on 5m.

In my workloads, the layers that actually benefit from 1h are:

  • The long system prompt (persona, output format, safety rails)
  • The tools JSON Schema block, especially when I have five or more tools defined
  • A shared knowledge "core" common across all users

Everything user-specific or daily-rotating stays on 5m.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
A concrete two-tier layout: 1h TTL for system/tools, 5m TTL for variable few-shot — with code
How to read cache_read_input_tokens vs. cache_creation_input_tokens to decide whether your TTL choice is correct
Numbers from my production workload (multiple iOS/Android apps and the four Dolice Labs sites) where this layout reduced input-token cost by about 42%
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

API & SDK2026-06-24
My Morning Batch Was Missing the Prompt Cache Every Time — Warming Cadence and the Break-Even Math for the 1-Hour TTL
Jobs that run a few hours apart cold-miss the prompt cache even with a 1-hour TTL. Here is how to back out the right warming interval from the TTL, and how to write the break-even formula that decides whether warming pays off — with numbers from a four-site daily generation pipeline.
API & SDK2026-04-26
How I Cut My Claude API Bill in Half With Prompt Caching
Done right, Anthropic's prompt caching can roughly halve your monthly API spend on workloads with long, repeated system prompts. Here is the design playbook I use after six months of running it in production.
API & SDK2026-07-13
Coalescing Concurrent Claude API Calls: Single-Flight Against Duplicate Inference and Cache Stampede
A design for collapsing identical prompts that fire at the same instant into a single upstream Claude call, using single-flight (request coalescing). In-process and distributed implementations, jittered retries, and negative caching, with measured results.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →