Skip to content

Guides

How to use sccache for Rust builds

Cargo rebuilds dependencies whenever the target directory cache misses.

5 min read

Cargo rebuilds dependencies whenever the target directory cache misses.

Why it happens

target/ caching only helps the branch that populated it; sccache works across branches and machines.

How to fix it

  1. Set RUSTC_WRAPPER to sccache and configure a shared S3 or Redis backend
  2. Cache ~/.cache/sccache as a local fallback
  3. Check sccache --show-stats so a silent zero hit rate does not go unnoticed

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.