ENABLE_PROMPT_CACHING_1H vs CLAUDE_CODE_PROMPT_CACHE_TTL
People think ENABLE_PROMPT_CACHING_1H is the way to set how long the cache lasts. It is one switch for everything. CLAUDE_CODE_PROMPT_CACHE_TTL sets the main chat alone, and its SUBAGENT twin sets the helpers. Both win over the switch. So set the switch for a quick change, and the two TTL variables when the main chat and helpers need different times.
ENABLE_PROMPT_CACHING_1H
Set to 1, it keeps the prompt cache for an hour.
ENABLE_PROMPT_CACHING_1H set to 1 asks for a saved prompt to last one hour, not the usual five minutes. It is for API key and cloud users. Subscription users get the hour on the main chat by default. Writing to the one-hour cache costs more, so it pays off only if you come back within the hour.
CLAUDE_CODE_PROMPT_CACHE_TTL
It sets the cache time for the main chat: 5m or 1h.
CLAUDE_CODE_PROMPT_CACHE_TTL sets how long a saved prompt lasts for the main chat. It takes 5m or 1h and nothing else. Its twin with SUBAGENT in the name does the same for subagents, workflows and work in the back. Both win over the one-hour switch and the settings. It needs version 2.1.242 or later.
In one line
- ENABLE_PROMPT_CACHING_1H
- Set to 1, it keeps the prompt cache for an hour.
- CLAUDE_CODE_PROMPT_CACHE_TTL
- It sets the cache time for the main chat: 5m or 1h.