You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pricing JSON is re-fetched from the network on every run — add a TTL disk cache #1412
Every non--O run blocks for several seconds re-downloading model pricing. Measured on my machine (v20.0.14):
command
run 1
run 2
run 3
ccusage daily -O (embedded)
0.34s
0.30s
0.29s
ccusage daily (online)
10.38s
8.00s
3.32s
The 10.4s run sits right at the 10s fetch timeout. Each run pulls the LiteLLM pricing JSON (~1.5 MB, ~1.5s) and, on the fallback path, models.dev (~2.8 MB, ~1.8s).
Cause
PricingMap::load_with_overrides → fetch_pricing_json / fetch_models_dev_json (rust/crates/ccusage/src/pricing.rs) only memoize in-process (OnceLock); nothing is persisted across invocations, so the network fetch repeats on every run.
Suggested fix
Cache the fetched JSON under $XDG_CACHE_HOME/ccusage (fallback ~/.cache/ccusage) with a TTL (e.g. 24h): a fresh cache hit skips the network, and on a network error we can serve the stale copy. This would cover both the LiteLLM and models.dev URLs, with no new dependencies (std fs/time plus the existing home module).
Note: this is distinct from #1245 (which is about caching usage logs) — this is specifically the pricing fetch.
This issue was auto-closed. Issues from new contributors are auto-closed by default.
Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.
Keep the issue short, concrete, and written in your own voice.
If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.
Historical audit: this discussion was auto-closed by the legacy contributor gate. That closure did not assess technical importance.
Audit result: maintainable candidate. The request fits the current ccusage scope and can be evaluated with repository-owned code or fixtures, without vendor credentials or platform-specific release infrastructure. It remains closed for now; reopen only after confirming current relevance and expected behavior.
Activity
github-actions commentedon Jul 9, 2026
This issue was auto-closed. Issues from new contributors are auto-closed by default.
Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.
Keep the issue short, concrete, and written in your own voice.
If a maintainer replies
lgtmi, your future issues will stay open. If a maintainer replieslgtm, your future issues and PRs will stay open.See CONTRIBUTING.md.
ryoppippi commentedon Aug 31, 2026
Historical audit: this discussion was auto-closed by the legacy contributor gate. That closure did not assess technical importance.
Audit result: maintainable candidate. The request fits the current ccusage scope and can be evaluated with repository-owned code or fixtures, without vendor credentials or platform-specific release infrastructure. It remains closed for now; reopen only after confirming current relevance and expected behavior.