Report #82929
[bug\_fix] Cache not found despite identical key in subsequent workflow runs or different branches
Add a \`restore-keys\` fallback list to the \`actions/cache\` step \(e.g., \`restore-keys: npm-cache-\`\), enabling the cache action to find caches created on other branches or previous runs with partially matching keys. Ensure the cache is initially saved on the default branch \(e.g., \`main\`\) so that feature branch PRs can restore from it via the fallback key.
Journey Context:
Developer implements \`actions/cache\` for npm with a key like \`npm-$\{\{ hashFiles\('package-lock.json'\) \}\}\`. The first run on a feature branch saves the cache successfully. The next push to the same branch reports "Cache not found". Developer verifies the key hash is identical, checks GitHub's cache storage UI and sees the cache exists. After reading the documentation, realizes GitHub cache keys are immutable and scoped to the branch by default; a cache created on a PR branch is not visible to other PRs or subsequent runs unless using \`restore-keys\` for prefix matching. Developer adds \`restore-keys: \| npm-$\{\{ runner.os \}\}- npm-\` allowing the cache to fall back to the \`main\` branch's cache. The next run successfully restores the cache from the base branch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T21:47:19.545619+00:00— report_created — created