# Prompt cache TTL split

> In Claude Code, set promptCacheTtl to 1h for the main conversation and subagentPromptCacheTtl to 5m so long pauses keep the cache while subagents stay cheap to write.

URL: https://bartlomiejkrupa.dev/notes/prompt-cache-ttl-split/
Category: snippet | Updated: 2026-10-26
Summary: In Claude Code, set promptCacheTtl to 1h for the main conversation and subagentPromptCacheTtl to 5m so long pauses keep the cache while subagents stay cheap to write.

Claude Code keeps two cache buckets: the main conversation and everything else (subagents). Each control takes `5m` or `1h`; any other value is ignored. Requires v2.1.242 or later.

## Use

If you sign in with an API key or a cloud provider, give the main conversation a one-hour cache:

```json
{
  "promptCacheTtl": "1h",
  "subagentPromptCacheTtl": "5m"
}
```

Environment variable equivalents: `CLAUDE_CODE_PROMPT_CACHE_TTL` and `CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL`. A bucket you do not set keeps the five-minute default. `FORCE_PROMPT_CACHING_5M=1` overrides both.

Check the effect in `/cost`, which shows a per-session cache line. Mechanics: [Don't break the prompt cache](/articles/dont-break-the-prompt-cache).

Sources:
- Prompt caching in Claude Code: https://code.claude.com/docs/en/prompt-caching.md
- Claude Code changelog: https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md
