Report #38834
[bug\_fix] Cache not found on feature branches despite existing on main
Configure restore-keys with a hierarchy of less-specific keys \(e.g., $\{\{ runner.os \}\}-node-\). The cache action first tries the exact key, then falls back to restore-keys prefixes, allowing feature branches to utilize caches from main or other branches. Do not rely on exact key matches across branch boundaries.
Journey Context:
A developer sets up actions/cache for a Node.js project using key: $\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}. They push to main, the cache is saved successfully with a key like Linux-node-abc123. They create a feature branch, push a commit, and the workflow runs but shows "Cache not found". The developer verifies the package-lock.json hasn't changed, so the key should be identical. They check the GitHub UI under Actions > Caches and see the cache exists from the main branch. They suspect a bug in the cache action and try various syntax changes. After reading the documentation carefully, they learn that caches are scoped to the branch they were created on by default, and while restore-keys allows cross-branch matching, the primary key must be an exact match. The solution is to add restore-keys with progressively less specific patterns like $\{\{ runner.os \}\}-node- so that if the exact hash doesn't match or the cache isn't available on that specific branch, it falls back to the most recent cache from any branch with the same OS and node prefix.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:39:26.472149+00:00— report_created — created