Skip to content
Latchkey

GitHub Actions cache restore-keys not matching prefix

restore-keys must be true prefixes of previously saved keys; if their structure differs from the primary key, no partial match is found and every miss falls all the way through to a cold cache.

What this error means

Even with restore-keys configured, the cache step still misses completely instead of restoring a recent partial entry.

github-actions
Cache not found for input keys: Linux-node-3f2a1b, npm-cache-
(restore-key 'npm-cache-' is not a prefix of any saved key)

Common causes

restore-keys not a prefix of the primary key

The restore-key uses a different leading structure than the primary key, so it can never prefix-match a saved entry.

Prefix too specific

The restore-key is so close to the full key that nothing older falls under it, giving no partial hit.

How to fix it

Align prefixes with the primary key

  1. Make each restore-key a leading substring of the primary key.
  2. Order restore-keys from most to least specific.
  3. Keep at least one broad prefix for any prior entry.
.github/workflows/ci.yml
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
  ${{ runner.os }}-node-
  ${{ runner.os }}-

How to prevent it

  • Build restore-keys as true prefixes of the primary key.
  • Order them most-specific to least-specific.
  • Verify a partial hit occurs after a key change.

Frequently asked questions

What causes ""restore-keys not matching""?
The restore-key uses a different leading structure than the primary key, so it can never prefix-match a saved entry.
How do I fix "restore-keys not matching"?
Align prefixes with the primary key

Related guides

References

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