Skip to content

Home / Blog / Caching

What does "Cache not found for input keys" mean in GitHub Actions?

"Cache not found for input keys" is a log line, not an error: nothing matched your key or restore-keys. Six reasons for the miss and what to change.

“Cache not found for input keys: Linux-node-3f2a…” is an information line, not an error: no GitHub Actions cache entry matched your key or restore-keys, so the step restored nothing and the job carries on. It is expected on a first run and after the key changes. Entries unused for 7 days are removed, and a cache saved on another branch may be out of reach.

In short
  • The cache action logs the line when no entry matched the key or any restore key; the step still succeeds.
  • On a miss the action saves a new cache under your key, but only if the job completes successfully.
  • A run can read caches from its own branch, the default branch and a pull request's base branch.
  • Entries not accessed for over 7 days are removed, and the default limit is 10 GB a repository.
  • The same key with a different path list or operating system is a different cache.
  • Test cache-hit != 'true', since the source does not set it to false on a miss.

Whether it is a problem depends on how often you see it. Once after a lockfile change is the cache working as designed; on every run means nothing is being reused. This post covers what the line means, the reasons for a miss in the order to check them, how to tell which is yours, and what to change.

What does “Cache not found for input keys” mean?

The cache action prints it. In its restore code, when the cache service returns no match for the primary key or any restore key, the action logs this line with every key it tried and returns normally. The step succeeds. GitHub’s caching reference calls this a cache miss and says what happens next: if the job completes successfully, the action saves a new cache under the key you gave.

The step fails on a miss only if you asked it to. With fail-on-cache-miss: true the same code throws “Failed to restore cache entry. Exiting as fail-on-cache-miss is set.” instead. Its default is false.

Why was the cache not found?

1. Nothing has been saved under this key yet. The first run with a new key always misses, and the save happens only if the job then succeeds. A job that misses, fails, and is retried misses again, because the failed run saved nothing.

2. The key changes on every run. A key that includes something different each time, a commit SHA, a run number or a timestamp, never matches an earlier entry exactly and is the start of no earlier key, so it can never hit. Only restore-keys, which match by prefix, can find an earlier entry for such a key.

3. The cache exists, on a branch this run cannot read. A run can restore caches created on its own branch or on the default branch, and a pull request run can also read its base branch. It cannot read a sibling branch’s. Caches saved by a pull request run are narrower still: GitHub’s reference says they are created for the pull request’s merge ref and can be restored only by re-runs of that pull request. So if the workflow never runs on the default branch, every new pull request starts with a miss.

4. The run that should have saved it was not allowed to. GitHub’s reference lists the triggers that may create a cache in the default branch’s scope: push, workflow_dispatch, repository_dispatch, delete, registry_package, page_build and schedule. A run on the default branch from any other event, such as pull_request_target or workflow_run, can restore but not save, unless the workflow or job declares a write-capable cache-mode.

5. It was evicted. An entry nobody has read for over 7 days is removed, and when a repository goes over its cache limit, 10 GB by default, the entries least recently used go first. A weekly job, or a repository with many large caches, meets this one.

6. Same key, different version. A cache is matched on its key and on a version, which the README describes as a hash of the path list and the compression tool, the latter depending on the runner’s operating system. Two jobs with the same key and different paths have two separate caches, and neither finds the other’s.

How do I tell which one I have?

Compare the key in the line with what is stored. The repository’s Actions tab has a list of cache entries that shows each one’s size, when it was created and when it was last used. It can be narrowed to a branch, or to a key with key: name in the filter box, which shows that key on every branch. The README points to the list-caches API for the version. If the key is not in the list at all, it is cause 1, 2 or 5: check whether the key in this run’s log differs from the last run’s. If the key is there on another branch, it is cause 3 or 4. If it is there on a branch you can read, it is cause 6.

How do I fix it?

Build the key from what the cached files depend on and nothing else: the operating system and a hash of the lockfile is the pattern in GitHub’s reference. Add a restore-keys prefix so that a changed lockfile starts from the most recent older cache instead of from nothing.

- uses: actions/cache@v4
  with:
    path: ~/.npm
    key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    restore-keys: |
      ${{ runner.os }}-npm-

Then make sure something saves on the default branch. Run the workflow on push to the default branch as well as on pull requests, so that every pull request has a cache it is allowed to read; that is the arrangement GitHub’s reference recommends. Keep the path list identical in every job that shares a key.

Is cache-hit false on a miss?

Do not rely on it. The README says cache-hit is false when no cache is restored, but the comment beside this log line in the action’s source says the output is intentionally not set to false there, to preserve existing behaviour. Write the condition the way the README does, steps.cache.outputs.cache-hit != 'true', which is right for a miss and for a restore from a restore key alike.

The cache reference lists every input and the reasons for a miss in more detail, the post on when a cache pays has the hit rate a cache needs to be worth having, and “Cache service responded with 429” is the message for a cache that was refused, not missed. A miss has the same causes on any runner. On ours you do not change your workflow to use the cache, and how the Actions cache works on our runners says how a job reaches it. Every size we run, with its memory, disk and rate a minute, is on our managed GitHub Actions runners page.

Sources

Frequently asked questions

What does "Cache not found for input keys" mean in GitHub Actions?

It is an information line, not an error. No cache entry matched your key or restore-keys, so the step restored nothing and the job carries on. It is expected on a first run and after the key changes. Entries unused for 7 days are removed.

Why was the cache not found?

Nothing was saved under the key yet, the key changes on every run, the cache is on a branch this run cannot read, the run that should have saved it was not allowed to, it was evicted, or its path list or operating system differs.

How do I fix it?

Build the key from the operating system and a hash of the lockfile, add a restore-keys prefix, keep the path list identical in every job that shares the key, and run the workflow on push to the default branch so pull requests have a cache to read.

Is cache-hit false on a miss?

Do not rely on it. The README says it is false when nothing is restored, but a comment in the action's source says the output is intentionally not set to false there. Test that cache-hit is not equal to 'true'.

Move your CI onto our runners with one line

Change one line, watch your own build, then decide.

Connect GitHub

Card required: a $5.00 authorisation, released at once and never charged. 3,000 minutes a month at 2 vCPU are included.

.github/workflows/ci.yml
jobs: test:removed: runs-on: ubuntu-latestadded: runs-on: runnersio-4vcpu-ubuntu-latest steps: - uses: actions/checkout@v4 - run: make testadded: build:added: runs-on: runnersio-32vcpu-ubuntu-latest