Skip to content

Cache hit rate only 40% and extremely slow - Claude Code

Quick fix

Disable the dynamic attribution header in .claude/settings.json; if that fails, switch to a model with working caching and monitor the main issue.

Error output
claude code接codex时,开启本地路由。命中率只有40%多,而且速度特别慢。但是codex自己运行时命中率有90%
English translation

When connecting claude code to codex with local routing enabled, the cache hit rate is only just over 40%, and it is extremely slow. But when codex runs by itself, the cache hit rate is 90%.

Claude Code injects a dynamic attribution header (CCH), which may break prompt caching for third-party models, reducing cache hit rates, increasing token usage, and significantly slowing responses. Related reports showed hit rates falling from over 90% to just over 70%, while another reported just over 40%.

Outcomes in the threads were inconsistent. One suggestion was to disable the dynamic header through `CLAUDE_CODE_ATTRIBUTION_HEADER`, but the original reporter still experienced slow responses and high token usage after setting it to `false`; switching to `minimax2.7` or `deepseek v4` restored normal behavior. Issue #3232 was closed as a duplicate, while Issue #3908 was closed after no new reproduction details were provided for a long time, so the corpus contains no confirmed universal fix.

  1. Add `CLAUDE_CODE_ATTRIBUTION_HEADER` to `.claude/settings.json` to try disabling the dynamic attribution header automatically generated by Claude Code.

    .claude/settings.json
    {
    "env": {
    "CLAUDE_CODE_ATTRIBUTION_HEADER": "false"
    }
    }
  2. Run the same request again and check the cache hit rate, response speed, and token usage. This setting did not resolve the problem in the Issue #3232 reporter's environment.

  3. If disabling the dynamic attribution header does not help, switch to `minimax2.7` or `deepseek v4`, which worked normally in the reporter's tests. This is only that user's observed result, not a confirmed universal fix.

  4. Issue #3232 was merged into the main issue for tracking. If the problem persists, provide the CC Switch version, system details, complete reproduction steps, and logs or screenshots.

ToolClaude Code
Version受影响版本:3.15.0
PlatformsWindows
Has this problem been resolved? Why does even a simple sentence take more than ten minutes to receive a response?
The existing threads contain no confirmed universal fix. The Issue #3232 reporter still experienced slow responses and high token usage after disabling the dynamic attribution header, but switching to `minimax2.7` or `deepseek v4` restored normal behavior.
Can setting `CLAUDE_CODE_ATTRIBUTION_HEADER="0"` resolve the lower cache hit rate?
Issue #3908 indicates that this environment variable can mitigate cache invalidation caused by the dynamic attribution header, but the Issue #3232 reporter saw no improvement with the value `false`, so the result may depend on the Claude Code version, model, or third-party provider integration.
Was this fixed after upgrading to CC Switch 4.0?
The maintainer said that related functionality was substantially refactored in 4.0 and recommended upgrading and trying again, but no user feedback in the thread confirms that the upgrade resolved the problem.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.