← Tue, Dec 1 digest

Claude 5-minute prompt cache vs GPT 30-minute cache: the cost of pauses

read article ↗ hn thread ↗

Claude's 5-minute default prompt cache TTL leads to significantly higher costs for coding agents compared to GPT's 30-minute TTL during short developer breaks.

read it Provides specific empirical data on cache miss rates and actionable implementation strategies for reducing LLM API costs.

summary

Analysis of 30 days of coding-agent traffic reveals that Claude users lose 23.1% of their bill to prompt cache rebuilds, compared to 9.3% for GPT, primarily due to Claude's shorter 5-minute default TTL. Short breaks (5-30 minutes) are the primary driver of these costs, as they trigger expensive cache writes (1.25x) instead of cheap reads (0.05x). The author suggests using 'keep-alive' pings (max_tokens: 0) every 4.5 minutes or switching to a 1-hour TTL after the first cache miss to mitigate these expenses.

key points

  1. Claude's 5-minute TTL causes 81% of breaks between 5 and 30 minutes to result in a full cache rebuild, whereas GPT's 30-minute TTL avoids most of these.
  2. For Claude Sonnet 5.5, a 5-30 minute pause costs an expected $0.28 per occurrence, compared to $0.008 for GPT-6.1 Sol, a 34x difference.
  3. Adaptive keep-alive pings (sending the last request with max_tokens: 0) can reduce Claude coding bills by 8-9% net.
  4. Switching to a 1-hour TTL mid-session on Anthropic API or Vertex often triggers a full rewrite at 2.0x cost rather than extending the existing cache.

who should read it

Engineers building LLM-powered agents or managing high-volume API spend for coding tools.

discussion positive

consensus

The 5-minute default is a 'footgun' for agentic workflows where tasks like compiling or testing often exceed 5 minutes. Most agree that monitoring cache hits is critical for budget estimation.

pushback

Some commenters argue the article is AI-written and overstates the impact for subscription users, who often have a 1-hour default for main agents.

best comment by edwinarbus ↗

Edwin from Anthropic here. Thanks for the thorough writeup. I will point out two things:

1. This looks like API-billed traffic only. Claude Code defaults to a 1 hour cache, not 5 min! So if you're within your plan's usage, this doesn't really apply [1].

2. In the API, we have 5 min and 1 hour TTL options. The "23%" here for the 5 min option includes breaks over 30 min, where both Claude's and GPT's default caches have expired and the loss is the ~same (7.8% vs. 8.5%). If you run long sessions with breaks, and are using an API key, you could set "ttl": "1h". There will be a bit higher write …

An Anthropic employee clarifies that Claude Code subscription plans default to 1-hour caching, limiting the article's impact primarily to API-billed users.

Generated by an LLM from the article and thread. Check the sources before relying on it.