GitHub Actions "Cache not found for input keys" - Fix actions/cache Misses
actions/cache found no entry for your key. Usually the key changes on every run (so nothing ever matches), or there is no restore-keys fallback for a partial match.
What this error means
The Restore cache step logs "Cache not found for input keys" and the job rebuilds dependencies from scratch every time, even when nothing changed.
Cache not found for input keys: npm-2f9c1a3b...
# next run uses a different hash, so it never hitsCommon causes
Key changes on every run
A key built from github.sha or a timestamp is unique per run, so a restore can never match a prior save.
No restore-keys fallback
Without restore-keys, an exact-key miss falls all the way through instead of restoring a recent partial match.
Cache never saved on the base branch
Caches are scoped by branch; a PR can read the base/default-branch cache, but if nothing saved it there first, there is nothing to restore.
How to fix it
Key on the lockfile, not the SHA
Hash the dependency lockfile so the key is stable across runs that did not change dependencies, and add a restore-keys prefix.
- uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-Seed the cache on the default branch
- Run the workflow on the default branch once so a cache is saved for PRs to restore.
- Confirm the save step actually ran (it is skipped on an exact-key hit).
- Keep the path the same between save and restore.
How to prevent it
- Build cache keys from lockfile hashes, never from the commit SHA.
- Always provide restore-keys for partial-match fallback.
- Prefer setup-* actions with built-in caching where available.