Skip to content
BENIBIX Learn

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.

AI⌨️ Claude Code

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.

Example
Lucy reads code for 20 minutes between prompts. With the five-minute cache, each prompt paid for a fresh start. With the hour, it does not.
Why it matters
Long gaps between prompts are normal in real work. A longer cache can save a lot there.
Full entry
AI⌨️ Claude Code

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.

Example
Jack's main chat sits idle for long spells, but his subagents finish fast. He gives the main chat 1h and the subagents 5m.
Why it matters
The main chat and the helpers have different gaps between calls, so one time does not fit both.
Full entry

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.