cache-refresher
A Claude Code mod that shows when your conversation's prompt cache expires and what rebuilding it would cost. It can also refresh the cache for you while you are away: that is off by default, and each refresh uses a little of your plan usage or API credit.
Claude Code reuses the cached part of your conversation at a fraction of the input price. The cache entry lives for five minutes or one hour after it was last used. Come back after that and your next message writes the conversation to the cache again, at 1.25 to 2 times the normal input price. This mod puts that clock where you can see it and does the arithmetic for you.
中文说明
What you get
- A status bar above the prompt: a ring that drains with the time left, the countdown, how many tokens are cached and what a rebuild would cost.
- A panel (
/cache-panel, or "Details ›" on the status bar): the countdown, the cost of an expiry next to the cost of one refresh, the break-even point, the auto-refresh switch with its limit, a "Refresh now" button and whether recent requests hit the cache.
- Auto-refresh, off by default: shortly before the cache would expire, the mod sends one small request that reads the cache, which restarts its lifetime. It stops at the limit you set. When the model's price is known, it also stops before the refreshes would cost more than one expiry adds. Until a refresh has been seen to extend the cache, it sends only one per idle period. While it is on, Claude Code's idle compaction is turned off, since it would otherwise compact a long conversation before the first refresh; it comes back on once no session has auto-refresh on.
- 43 languages, the same set the Claude desktop app ships. The mod matches the language Claude is replying in;
/cache-lang sets one. Apart from English and Chinese the translations are machine-made and have not been checked by native speakers: corrections are welcome as issues or pull requests.
On the desktop app the ring and the panel are drawn and animated. In the terminal the same information is drawn in text.
Commands
| Command | What it does |
|---|
/cache-status | Prints the cache's status, its lifetime and the source of that lifetime, and the cost figures |
/cache-panel | Opens the panel |
/cache-ping [force] | Refreshes the cache now. Refused when the cache has already expired, unless force |
/cache-auto [on|off] [max] | Shows or changes the auto-refresh settings: on or off, and the maximum refreshes per idle period (default 12) |
/cache-lang [auto|code] | Sets the display language by its code (for example ja, de, pt-BR), or goes back to matching the conversation |
Examples
- See what stepping away costs. After a long turn, run
/cache-status. It prints how long the cache has left, how many tokens it holds, and what rebuilding them would cost next to the cost of one refresh.
- Keep the cache active over lunch. Run
/cache-auto on 12, or open /cache-panel and press "Turn on". The status bar shows the count as 0/1 until a refresh has been seen to work and then up to your limit; the panel estimates how long the cache can be kept. Your next message resets the count.
- Extend the cache before a meeting. Run
/cache-ping, or press "Refresh now" in the panel. The reply says how many tokens were read from the cache and what the refresh cost, and the countdown starts over.
The arithmetic
A refresh reads the cached prefix at the cache-read price r, plus a few dozen tokens for the request itself. After an expiry the prefix is written again at the cache-write price w, which is w − r more than a hit would have cost. Refreshes are worth sending while their total stays under that difference, which gives at most about (w − r) / r refreshes in a row, and a refresh pays off whenever the chance you come back within its window is above about r / (w − r). For most models that is a few percent. /cache-status shows both numbers for your model and cache size.
Which lifetime applies is read from the environment variables Claude Code itself honors (FORCE_PROMPT_CACHING_5M, CLAUDE_CODE_PROMPT_CACHE_TTL, ENABLE_PROMPT_CACHING_1H). With none of them set, the mod assumes one hour on a subscription inside its plan limits and five minutes elsewhere. When Claude Code itself gives the lifetime (at a model switch, and on a resume that comes between five minutes and an hour after the last response), the mod uses that in place of its own assumption, except past the plan's limits. Either way it corrects the lifetime from what it observes.
Dollar figures are computed at API list prices. On a subscription they are an equivalent, not a charge.
What it reads, stores and sends