Guides
How to write a cache key that hits
The cache is configured but misses on every run.
4 min read
The cache is configured but misses on every run.
Why it happens
The key includes something that changes per run, or excludes something that changes the content.
How to fix it
- Hash exactly the files that determine the content — usually lockfiles
- Include runner.os and runner.arch so caches do not cross-contaminate
- Never include github.sha or a timestamp
- Add restore-keys so a partial match still helps
Your next build could be twice as fast, at half the price
Start free. Migrating away is the same one line, and we publish that diff too.
Related
How to make CI caches actually persistCaches are configured but hit rate is low.How to work around the 10 GB cache limitYour caches exceed 10 GB per repository and start silently evicting.How to share a build cache across repositoriesEach repository maintains its own cache for the same shared dependencies.How to share a Docker cache between jobsEach matrix leg rebuilds the same layers.