# sccache in GitHub Actions, measured: the GHA backend, a local directory and target/

First and second build times for a 13-member Rust workspace on ubuntu-24.04 with sccache's GitHub Actions backend, a local directory and target/, five runs each.

By Grant Unwin, published 2026-10-30. Checked against GitHub's documentation on 2026-11-17. The web page: https://www.runners.io/blog/sccache-github-actions-measured

On a 13-member Rust workspace on GitHub’s ubuntu-24.04 runner, a debug build took a median of 62.0 seconds with no cache. A second run took 40.2 seconds with sccache’s GitHub Actions backend, 35.2 with sccache and a saved local directory, and 28.4 with `target/` cached, after a 14.8-second restore. The first run with sccache was slower than no cache at all: 97.9 and 88.3 seconds. Our [GitHub Actions cache](https://www.runners.io/blog/github-actions-cache-limit) guide has the full rules.

**In short**

- A debug build of a 13-member Rust workspace took a median of 62.0 seconds on ubuntu-24.04 with no cache.
- A second run took 40.2 seconds with sccache's GitHub Actions backend, 35.2 with a local directory, and 28.4 with target/ after a 14.8-second restore.
- The first run with sccache was slower than no cache: 97.9 and 88.3 seconds.
- sccache stored 256 of 318 compile requests; 54 could not be cached, among them crates of type bin and procedural macros.
- With three pairs of builds at once the GitHub Actions backend lost a median of 176 writes; one pair at a time, 11.

## What did we build, and how?

The workspace is [helix](https://github.com/helix-editor/helix) at tag 25.07.1: 13 workspace members and 321 locked packages. We turned off the one part of its build that is not compilation, a script that fetches and builds 245 tree-sitter grammars from git, and ran `cargo build --workspace --locked` with incremental compilation off, because sccache cannot cache incrementally compiled crates. Every cell ran in its own job on a fresh runner in a public repository, where a standard Linux runner has 4 vCPUs and 16 GB of memory. A private repository’s `ubuntu-24.04` has 2 vCPUs and 8 GB, so expect longer times there.

Four arms, five repetitions each: no cache; `target/` saved and restored with `actions/cache`; sccache 0.19.0 with its GitHub Actions backend; and sccache with a local directory that `actions/cache` saved and restored. A “first” run is a build with nothing cached. A “second” run is the same commit on a new runner with the first run’s cache, as the next push would be. Every cache key, and sccache’s own cache version, carried the run and the repetition, so no repetition could read another’s cache. The crate download is timed on its own and left out of the build time, and the pairs ran one at a time (the reason is below). A pair is one repetition: its four arms ran at once, then its three second runs.

## What do the numbers say?

*Bar chart. Median debug build time of a 13-member Rust workspace on ubuntu-24.04, by cache arm and run, in seconds (5 runs a cell). No cache, first run 62.0 seconds, target/ with actions/cache, first run 62.2 seconds, target/ with actions/cache, second run 28.4 seconds, sccache, GitHub Actions backend, first run 97.9 seconds, sccache, GitHub Actions backend, second run 40.2 seconds, sccache, local directory, first run 88.3 seconds, sccache, local directory, second run 35.2 seconds.* Data: [run 44078371515 of studies/C1-sccache](https://github.com/runners-io/ci-measurements/actions/runs/44078371515)

| Arm | Run | Restore | Build | Save | sccache, of 256 cacheable |
| --- | --- | ---: | ---: | ---: | --- |
| No cache | first | none | 62.0 (52.1 to 62.6) | none | none |
| target/ with actions/cache | first | 4.0 (0.5 to 10.7) | 62.2 (57.9 to 102.2) | 9.1 (6.8 to 16.8) | none |
| target/ with actions/cache | second | 14.8 (7.7 to 21.7) | 28.4 (25.8 to 30.7) | none | none |
| sccache, GitHub Actions backend | first | none | 97.9 (77.4 to 113.5) | none | 0 hits; 11 failed writes (0 to 44) |
| sccache, GitHub Actions backend | second | none | 40.2 (28.7 to 68.9) | none | 245 hits (212 to 256) |
| sccache, local directory | first | 0.3 (0.2 to 0.3) | 88.3 (75.1 to 97.9) | 2.5 (0.6 to 2.8) | 0 hits |
| sccache, local directory | second | 2.0 (0.4 to 5.4) | 35.2 (20.9 to 71.4) | none | 256 hits in 4 runs; 0 in the fifth |

The figures are medians of five runs, with the lowest and highest in brackets, and the build column is the time of the build step alone. Three things stand out.

**At the median, all three caches cut a build, and none cost nothing.** In every arm the median second build was shorter than the 62.0 seconds of no cache. Two of the ten second runs, at 68.9 and 71.4 seconds, were slower than that median. With `target/` the build was 28.4 seconds, but restoring 2,238 MB in 2,289 files took 14.8, so the two steps together, the sum of the medians, took 43.2. With the local directory the build step was 35.2 and the restore 2.0. With the GitHub Actions backend there was no restore step and a build of 40.2, reading from the cache as it compiled.

**The first run pays.** With sccache the first build took 97.9 seconds (GitHub Actions backend) and 88.3 (local directory), against 62.0 with no cache. We did not break that extra time down. The `target/` arm had a smaller first-run cost: a build of 62.2, a 4.0-second restore that found nothing and a 9.1-second save. If your branches rarely hit a warm cache, that is the number to weigh.

**One restore found nothing.** In one of the five repetitions of the local-directory arm the second run found no entry and compiled all 256 crates again, which is why its highest build time is 71.4. We kept it in the medians. The repository’s cache is shared with other studies we ran that day, and an eviction by one of them cannot be ruled out; we did not establish the cause.

We also built the release profile. Because only two of its five repetitions completed, we publish no figures for it, and the rows are in the repository.

## What does each arm look like in a workflow?

The three cached arms differ in a few lines. All three set `CARGO_INCREMENTAL` to 0. The two sccache arms need it, because sccache cannot cache incrementally compiled crates and exits with an error if it is on; the study set it in every arm so that the builds compare.

```yaml
# 1. target/ with actions/cache
- uses: actions/cache@v6
  with:
    path: target
    key: ${{ runner.os }}-target-${{ hashFiles('**/Cargo.lock') }}
- run: cargo build --workspace --locked
  env:
    CARGO_INCREMENTAL: "0"
```

```yaml
# 2. sccache with its GitHub Actions backend
- uses: mozilla-actions/sccache-action@v0.0.11
- run: cargo build --workspace --locked
  env:
    CARGO_INCREMENTAL: "0"
    RUSTC_WRAPPER: sccache
    SCCACHE_GHA_ENABLED: "true"
- run: sccache --show-stats
```

```yaml
# 3. sccache with a local directory that actions/cache saves and restores
- uses: mozilla-actions/sccache-action@v0.0.11
- uses: actions/cache@v6
  with:
    path: ~/.cache/sccache
    key: sccache-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
    restore-keys: |
      sccache-${{ runner.os }}-
- run: cargo build --workspace --locked
  env:
    CARGO_INCREMENTAL: "0"
    RUSTC_WRAPPER: sccache
    SCCACHE_DIR: /home/runner/.cache/sccache
```

The third arm needs one more thing than it looks. The study ran `sccache --stop-server` before the save step; we did not test the arm without it. The keys in the study carried the run so the first run was truly cold; yours should be keyed as above so that a changed `Cargo.lock` starts from the nearest older directory instead of from nothing.

## What can sccache not cache?

sccache does not cache a crate that invokes the system linker. In sccache’s documentation that means `bin`, `dylib`, `cdylib` and `proc-macro` crates. In this workspace 318 compile requests reached sccache. It compiled and stored 256 of them and could not cache 54: 32 with crate type bin, 9 procedural macros and 13 for other reasons the statistics list. The other 8 were not compiles or failed ones. So a second run still links and compiles those 54 again. The documentation’s suggestion for a large binary crate is to move its code into a library with a thin binary on top.

## Why did the GitHub Actions backend lose writes when we ran more at once?

The first time we ran this, three pairs of builds ran at once in the same repository. The GitHub Actions backend then recorded a median of 176 failed cache writes in its first run (67 to 182), and its second run found a median of 80 hits out of 256 (74 to 189). Run one pair at a time, the same arm recorded a median of 11 failed writes (0 to 44; three of the five runs lost some) and 245 hits (212 to 256). The numbers in this post are from the second run of the study. The release of sccache we used, 0.19.0, has no retry layer in its GitHub Actions client; one was added on its main branch afterwards.

We cannot say the cause was HTTP 429 from the statistics, which count failed writes without their status, and the rate limit was not the only thing that changed. In the first run the second runs of the other two caches also missed, in all five pairs for `target/` and two of five for the local directory, and each of those saves one entry, not hundreds. The repository’s cache is shared with other studies and has a 10 GB limit, so eviction is a second suspect. But GitHub limits a repository to 200 cache uploads and 1,500 downloads a minute, shared by every job in it, and sccache stores each compilation as its own cache entry: a single build of 256 caches is near that limit alone. sccache’s documentation says that when it reaches the service’s rate limit the build continues but storage might not be performed, which is what the failed writes looked like: no failed builds, and a second run that had less to hit. Our [post on the 429 error](https://www.runners.io/blog/github-actions-cache-service-responded-with-429) has the limits and what a job does when it meets them; the [cache limit post](https://www.runners.io/blog/github-actions-cache-limit) has the 10 GB and the eviction rules.

## Which should I use?

On this workload, once a cache existed, any of the three cut the second build, and the ranges overlap enough that the choice comes down to what each costs you to run. `target/` is the simplest and has the smallest first run, but it is 2,238 MB in 2,289 files on disk, and restoring it took 14.8 seconds here. The local directory is the smallest thing to move, 251 MB in 257 files on disk, and uploads one entry, but you carry the cache steps and the stop-server step. The GitHub Actions backend is two lines of configuration and no cache steps, and is the one that can lose writes when several jobs build at once, as a matrix does. Whichever you pick, let the default branch build the cache, restore it elsewhere, and look at `sccache --show-stats` in the log before you trust it. A build with 0 hits in its second run is a cache that did not work.

We expect sccache to pay when the same crates are compiled more than once across jobs and branches; we did not measure a workspace whose dependencies change on every push, where hits would be fewer and the first-run cost above would count for more. For Gradle, Go and ccache, see the [guide to keeping a build cache between runs](https://www.runners.io/blog/persist-build-cache-between-github-actions-runs); for the time a restore costs against the work it replaces, the [break-even post](https://www.runners.io/blog/github-actions-cache-or-rebuild-break-even).

## What changes on runners.io?

The local-directory arm uses `actions/cache`, which works unmodified on our runners (see the [Actions cache documentation](https://www.runners.io/docs/caching/actions-cache)). We have not measured sccache on our runners and make no claim about its backend there. A directory that has to outlive the job is also what [sticky disks](https://www.runners.io/docs/caching/using-sticky-disks) are for; read their page for how they are turned on and billed. Build times measured on GitHub’s runner and on ours are on our [faster GitHub Actions runners, measured](https://www.runners.io/faster-github-actions) page.

## Sources

- [mozilla/sccache](https://github.com/mozilla/sccache)
- [sccache: GitHub Actions cache](https://github.com/mozilla/sccache/blob/main/docs/GHA.md)
- [sccache: Rust](https://github.com/mozilla/sccache/blob/main/docs/Rust.md)
- [mozilla-actions/sccache-action](https://github.com/mozilla-actions/sccache-action)
- [actions/cache](https://github.com/actions/cache)
- [GitHub-hosted runners reference](https://docs.github.com/en/actions/reference/runners/github-hosted-runners)
- [Dependency caching reference](https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching)
- [helix-editor/helix](https://github.com/helix-editor/helix)
- [runners-io/ci-measurements, study C1 (workflows, method and raw rows)](https://github.com/runners-io/ci-measurements/tree/main/studies/C1-sccache)
- [sccache-action releases](https://github.com/mozilla-actions/sccache-action/releases)

## Frequently asked questions

### Does sccache work with the GitHub Actions cache?

Yes. Set SCCACHE\_GHA\_ENABLED to true and RUSTC\_WRAPPER to sccache, with the mozilla-actions/sccache-action step. In our runs a second build took a median of 40.2 seconds against 62.0 with no cache.

### Is sccache faster than caching target/ in GitHub Actions?

Not clearly. A second build took a median of 35.2 to 40.2 seconds with sccache and 28.4 with target/ cached, but target/ took 14.8 seconds to restore. The ranges overlap, and sccache's first run was slower.

### What can sccache not cache in a Rust build?

Crates that invoke the system linker: binaries, dylibs, cdylibs and procedural macros. In our workspace 32 requests had crate type bin and 9 were procedural macros, of 318 compile requests. Incremental compilation must also be off.

### Why does sccache lose cache writes in GitHub Actions?

GitHub limits a repository to 200 cache uploads a minute, and sccache stores each compilation as an entry. sccache's documentation says a build continues when it hits the rate limit but storage might not happen.
