Skip to content

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

  1. Hash exactly the files that determine the content — usually lockfiles
  2. Include runner.os and runner.arch so caches do not cross-contaminate
  3. Never include github.sha or a timestamp
  4. 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.