GitHub Actions · infra · fg-0223

actions/cache never updates: 'Cache hit occurred on the primary key, not saving cache'

If you see Cache hit occurred on the primary key node-cache, not saving cache, the cause and the fix for GitHub Actions are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
Cache hit occurred on the primary key node-cache, not saving cache.Dependencies or build output in the cache stay stale for weeksChanging files under the cached path does not change what is restored
Cause
A cache entry is immutable once saved, so a key that never changes is restored forever and never written again. New content needs a new key.
Fix
Put a content hash in the key and use restore-keys for partial matches.
Apply
- uses: actions/cache@v4 with: path: ~/.npm key: npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} restore-keys: | npm-${{ runner.os }}-
Affected
actions/cache v3 and v4 on github.com, as of October 2026
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun