Report #53566
[bug\_fix] Cache not found in pull request builds despite existing on default branch
Add restore-keys with a prefix match \(e.g., \`$\{\{ runner.os \}\}-node-\`\) to allow fallback to caches from other branches, or ensure base branch has cache before PRs are opened
Journey Context:
Developer notices their Node.js build takes 15 minutes because node\_modules isn't cached. They add actions/cache with key: \`$\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`. First run on main branch saves cache. They open a PR. The workflow runs but says 'Cache not found'. They check the key - it's identical to main. They search documentation and discover cache isolation: caches are scope-restricted to the branch they were created on and its base branch. The PR branch cannot see main's cache unless it was created before the PR, or unless restore-keys is used. They add restore-keys: \`$\{\{ runner.os \}\}-node-\` which allows fallback to any node cache from any branch, solving the immediate miss. They realize the proper long-term fix is ensuring the base branch cache is populated before PRs are opened, or accepting slightly stale dependencies via restore-keys.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T20:24:33.064264+00:00— report_created — created