Report #36593
[bug\_fix] Cache restore always misses because key includes github.sha or timestamp
Use a stable cache key derived from dependency lockfiles using \`hashFiles\('\*\*/package-lock.json'\)\`, and provide \`restore-keys\` with a prefix \(e.g., \`npm-linux-\`\) to allow partial matches on older caches when lockfiles change.
Journey Context:
Developer notices their workflow installing node\_modules takes 4 minutes every run despite using \`actions/cache\`. Logs show "Cache not found for input keys: linux-npm-a1b2c3d..." where the hash changes every commit. They realize they used \`key: $\{\{ runner.os \}\}-npm-$\{\{ github.sha \}\}\` thinking each commit needed its own cache. After removing the SHA, they find all branches share one cache that grows infinitely and often has wrong dependencies. They eventually find the pattern in GitHub docs: hash the lockfile \`key: $\{\{ runner.os \}\}-node-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\` with \`restore-keys: $\{\{ runner.os \}\}-node-\`. This gives exact match when dependencies are identical, or falls back to the most recent cache if lockfile changed \(allowing npm/yarn to efficiently update node\_modules rather than cold install\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:54:14.380084+00:00— report_created — created