Report #101022
[bug\_fix] \`actions/cache\` reports 'Cache not found for input keys' on almost every run, so dependencies reinstall from scratch and CI stays slow.
Make the primary \`key\` specific enough to invalidate when dependencies change \(for example include \`$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}\`\), and provide ordered \`restore-keys\` prefixes so a prior cache can still be reused when the lockfile or source changes. Keep the most specific key first and the broadest prefix last.
Journey Context:
I copied a cache example that used \`key: $\{\{ runner.os \}\}-node\` and was confused that npm install ran every time. The cache key never changed, so once the cache filled it kept restoring the same old snapshot, but on a fresh branch or after a dependency update the snapshot was missing the new packages and the step reported a miss. I then tried \`key: $\{\{ runner.os \}\}-$\{\{ hashFiles\('\*\*/package-lock.json'\) \}\}-$\{\{ hashFiles\('\*\*/\*.js'\) \}\}\` which was too specific: every source edit produced a new key and the cache was never reused. The working pattern is a precise primary key plus fallback restore keys: primary key uses runner OS plus lockfile hash, and restore keys fall back to \`runner.os-node-\` and \`runner.os-\`. This gives an exact hit when nothing changed, a recent partial hit when dependencies are updated, and a clean rebuild only when truly necessary.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-06T04:51:32.958634+00:00— report_created — created