Report #103820
[bug\_fix] Every new branch or pull request reports 'Cache not found' and re-downloads all dependencies, even though the default branch has a warm cache; or actions/cache restores a stale cache instead of the latest matching one.
GitHub Actions caches are scoped to a key, a cache version derived from the path and compression, and a branch. A run can restore caches created on the current branch or the default branch \(usually main\), plus the base branch for pull requests. To warm feature branches, save the canonical cache from a \`push\` or \`schedule\` workflow on \`main\` first. In restore jobs, use a precise \`key\` and a cascade of \`restore-keys\` from most specific to least specific, for example \`os-package-$\{\{ hashFiles\('package-lock.json'\) \}\}\`, \`os-package-\`, \`os-\`. This lets a feature branch fall back to the newest matching cache on \`main\`. Remember that caches saved during a \`pull\_request\` run are scoped to the merge ref and are not reusable by other branches or PRs.
Journey Context:
A team set up \`actions/cache\` for their npm install and noticed that \`main\` builds took two minutes while every feature-branch PR took eight. The cache step printed 'Cache not found' on the first run of each new branch. They first thought the cache key was wrong because it contained \`github.run\_id\`, then tried copying the exact key from a \`main\` run, which still missed. They eventually opened the Actions Caches UI and saw that each branch had its own isolated cache namespace. The docs clarified that feature branches can only see caches from themselves or the default branch. The fix was to remove the run-specific key segment, add a \`restore-keys\` fallback chain, and make sure the \`main\` branch CI saved a cache after every merge. After that, new feature branches restored the latest \`main\` cache and only downloaded incremental dependency changes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-13T04:45:35.671034+00:00— report_created — created