Report #47851
[bug\_fix] Cache not found or 100% cache miss rate on every run despite no dependency changes, because the cache key is unique on every run
Use a stable cache key based on deterministic file checksums that change only when dependencies change \(e.g., \`key: $\{\{ runner.os \}\}-npm-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`\) and use \`restore-keys\` for partial fallback. Avoid using dynamic values like \`$\{\{ github.sha \}\}\`, \`$\{\{ github.run\_id \}\}\`, or timestamps in the primary cache key.
Journey Context:
A developer notices their Node.js workflow takes 15 minutes to install dependencies on every single commit, even for README changes. They check the post-job cache save step and see "Cache saved successfully with key: Linux-npm-abc123...". On the next run, the restore step says "Cache not found for input keys: Linux-npm-def456...". They realize the key includes \`$\{\{ github.sha \}\}\` which is unique per commit. They remove the SHA from the key and instead use \`$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`. On the next run, the cache restores in 8 seconds, skipping the npm install entirely. They also add \`restore-keys: Linux-npm-\` as a fallback for when the lockfile changes partially.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T10:47:54.032024+00:00— report_created — created