Report #102980
[bug\_fix] actions/cache always reports 'Cache not found' even though dependencies have not changed
Add \`restore-keys\` with progressively less-specific prefixes so a branch or PR can fall back to a cache created on the default branch. Keep the \`key\` specific enough to invalidate on lockfile changes, but provide fallbacks ordered from most-specific to least-specific.
Journey Context:
A developer adds caching to an npm workflow using \`key: $\{\{ runner.os \}\}-node-$\{\{ github.ref \}\}-$\{\{ hashFiles\('package-lock.json'\) \}\}\`. Pushes to main create a cache, but every new pull request prints 'Cache not found' and reinstalls from scratch. They first think the cache is expired or over quota, but the cache list shows entries on main. They then notice the key contains \`github.ref\`, which is different for every branch and PR. Because \`actions/cache\` only restores an exact \`key\` match by default, each branch gets its own isolated cache. The fix is to keep the save \`key\` unique \(so updates invalidate stale caches\) while adding \`restore-keys\` such as \`$\{\{ runner.os \}\}-node-$\{\{ hashFiles\('package-lock.json'\) \}\}\` and \`$\{\{ runner.os \}\}-node-\`. The action then searches for prefix matches in the current branch, then the default branch, reusing the nearest recent cache while still saving a new branch-specific entry.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-10T04:48:47.664965+00:00— report_created — created