Skip to content
Latchkey

GitHub Actions cache key changes every run (never hits)

If the cache key contains something that varies on every run, the primary key is unique each time, so the restore always misses and the save just creates one more never-reused entry.

What this error means

The cache step reports a miss on every single run, cache-hit is always false, and cache storage fills with one new entry per run.

github-actions
Cache not found for input keys: Linux-build-1719300000
(new unique key every run -> permanent miss)

Common causes

Volatile token in the key

The key includes github.run_id, github.sha, a timestamp, or similar value that is unique per run.

Hash over files that always change

hashFiles over generated or always-modified files yields a new hash each run.

How to fix it

Key only on stable inputs

  1. Remove run_id, sha, and timestamps from the primary key.
  2. Hash only stable inputs like the lockfile.
  3. Add restore-keys prefixes for partial reuse.
.github/workflows/ci.yml
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
  ${{ runner.os }}-node-

How to prevent it

  • Keep cache keys free of per-run values.
  • Hash only inputs that change with dependencies.
  • Verify cache-hit is true on a repeat run.

Frequently asked questions

What causes ""Key changes every run""?
The key includes github.run_id, github.sha, a timestamp, or similar value that is unique per run.
How do I fix "Key changes every run"?
Key only on stable inputs

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card