Report #30774
[bug\_fix] Cache restore misses despite previous successful save
Use the \`restore-keys\` input with a prefix match strategy. List keys from most specific to least specific \(e.g., \`os-node-$\{\{ hashFiles\('package-lock.json'\) \}\}\`, then \`os-node-\`\). This ensures a partial fallback if the exact lockfile hash changes.
Journey Context:
A developer configures \`actions/cache\` to cache \`node\_modules\` using a key based on \`hashFiles\('\*\*/package-lock.json'\)\`. The first run saves the cache successfully. They push a commit that modifies a source file but not \`package-lock.json\`. The workflow runs again but reports "Cache not found for input keys" and reinstalls dependencies from scratch. The developer inspects the key generation and realizes that they added \`$\{\{ matrix.node \}\}\` to the key in the second commit, changing the key format so it no longer matches the saved cache. Or they realize that \`hashFiles\` found multiple lockfiles in \`node\_modules\` subdirectories \(if cache wasn't clean\), creating a different hash. They read the documentation and understand that \`restore-keys\` allows prefix matching, so adding \`restore-keys: $\{\{ runner.os \}\}-build-$\{\{ env.cache-name \}\}\` allows hitting the cache even if the exact file hash changes slightly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:02:17.043096+00:00— report_created — created