How to Debug a Cache Key Miss in GitHub Actions
A cache that never restores usually has a key that changes every run or a path that is empty at save time.
The step log prints the resolved key and either "Cache restored from key" or "Cache not found for input keys". Compare the key across two runs. If it differs when it should not, your hashFiles glob matches a file that changes, or the key includes a per-run value.
Steps
- Read the "Cache not found for input keys" line to see the exact key tried.
- Print
hashFiles(...)to confirm it is stable across runs. - Confirm the cached path actually contains files at save time.
Print the resolved key
.github/workflows/ci.yml
- run: echo "key=deps-${{ runner.os }}-${{ hashFiles('package-lock.json') }}"Common causes
- The key contains
github.shaor a timestamp, so it never repeats. - The path is empty because install runs before the cache save is meaningful.
- hashFiles matched nothing (empty hash), so the key never changes but nothing was ever saved under it.
Related guides
How to Use the cache-hit Output to Skip Work in GitHub ActionsRead the cache-hit output of actions/cache in GitHub Actions to conditionally skip a rebuild or reinstall ste…
How to Build a Cache Key With hashFiles in GitHub ActionsUse the hashFiles expression to derive a cache key from one or more lockfiles in GitHub Actions, so the key c…