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
perf(scripts): cache registry responses so --check runs in 0.05s instead of 29s (#3062)
`--check` makes one HTTPS request per tracked component — 46 round trips
for a run that is almost entirely I/O wait: 28.6s wall against 0.13s of
user time. That is enough friction that nobody runs the status command,
which rather defeats having one.
Responses are now cached under `node_modules/.cache/shadcn-sync/`, keyed
by source URL, with a 60-minute TTL:
cold (empty cache) 26.86s 0 cached, 46 fetched
warm 0.05s 46 cached, 0 fetched
--no-cache 28.74s 0 cached, 46 fetched
`node_modules/.cache/` is the conventional home: already gitignored
(verified via git check-ignore), and a clean install discards it, which
is the right lifetime for a cache.
The load-bearing detail is that `allowCache` gates READS only, and only
read-only commands pass it. `--check` and `--diff` may answer from cache;
`--update` and `--update-all` never do. A stale `--check` is a slightly
out-of-date status line, but a stale `--update` would put hour-old code
on disk under a message saying it is current. Writes still refresh the
entry, so an update leaves the cache warm for the next check.
Proved that split by poisoning the cached `button` entry:
`--check` reported button as 51-line modified — it reads the cache — while
`--update button` ignored the poison entirely, wrote the real upstream
content (clean tree, zero POISONED lines), and write-refreshed the entry.
Degradation is quiet by design: a missing, unreadable or corrupt entry
falls through to the network (garbage file → 45 cached, 1 fetched, exit
0), and a cache directory that cannot be written never fails the run.
Expiry verified by ageing every entry to 61 minutes — 0 cached, 46
fetched.
The summary always reports where the data came from. A run that returns
in 50ms is otherwise indistinguishable from one that silently fetched
nothing.
Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
0 commit comments