quickstart →

sccache compilation cache

sccache remote cache for Rust, C and C++ builds on GitHub Actions, served by Magic Cache from your own S3 bucket with GitHub's branch scopes.

Magic Cache stores sccache ↗’s compilations in the cache bucket of your stack, for Rust, C and C++ builds, in one of two ways.

Availability#

On runners with Magic Cache (extras=s3-cache), with Flex and Fleet: remote_cache: sccache since v3.6.0, the GitHub Actions cache mode since v3.5.0.

Enable it (remote_cache: sccache)#

remote_cache: sccache in runs-on/action@v2 ↗ points sccache’s WebDAV backend at the RunsOn agent. The agent stores the entries in the stack’s cache bucket with GitHub’s cache scopes: a pull request reads its base branch’s entries and writes only its own. Cache isolation covers them. sccache sends no token: the action gives the job’s runtime token to the agent, and no later step sees it. Install sccache (we test with 0.18.0) before compiling:

.github/workflows/ci.yml
- uses: runs-on/action@v2
with:
remote_cache: sccache
- uses: taiki-e/install-action@v2
with:
tool: sccache
- run: cargo build --release --locked

Later steps get RUSTC_WRAPPER=sccache, and C or C++ builds can use sccache as their compiler launcher. For Rust, turn incremental compilation off (CARGO_INCREMENTAL=0), which sccache cannot cache. See the action’s README ↗ for the details.

GitHub Actions cache mode#

Since v3.5.0, Magic Cache also serves sccache’s GitHub Actions cache backend (SCCACHE_GHA_ENABLED=true). Earlier versions returned an upload URL that sccache rejects, so sccache never saved anything. In this mode, sccache follows GitHub’s cache scopes like actions/cache: a branch reads its own entries, then the default branch’s. To use it, set SCCACHE_GHA_ENABLED: "true" and RUSTC_WRAPPER: sccache in the job’s env instead of the remote_cache input.

The Rust guide compares sccache with Swatinem/rust-cache on a large workspace. The older sccache: s3 input is on Legacy caching options.