sccache is a general-purpose compiler cache for Rust projects. It stores unchanged compiler outputs so repeated builds avoid recompiling previously compiled code. section 3.5
Use sccache when repeated compilation time affects local development or CI/CD:
- Install it with Cargo, then expose it to Cargo through the RUSTC_WRAPPER environment variable. section 3.5.1
- Use local storage by default, or configure networked S3, Redis, or Memcached-compatible backends for shared build caching. section 3.5.2
- Expect benefits only after compilation results exist; sccache does not accelerate a completely fresh build. section 3.5
$ cargo install sccache
Install sccache with Cargo before configuring it as Cargo’s rustc wrapper. section 3.5.1
$ export SCCACHE_REDIS=redis://10.10.10.10/sccache #1
Point sccache at a Redis backend by setting SCCACHE_REDIS to a Redis address. section 3.5.2
Measured local improvement
A clean dryoc build took 8.891 seconds normally and 5.839 seconds with sccache enabled, making the uncached run 52% slower. section 3.5
