#fetch #git #cargo #logging #sync #index #path

app cargo-cacher

cargo-cacher is a crates.io proxy that will proxy requests made when building a package with Cargo

16 releases (9 stable)

Uses old Rust 2015

1.2.5 Jul 1, 2020
1.2.2 Feb 29, 2020
1.2.1 Jan 27, 2020
1.1.0 Dec 9, 2016
0.1.2 Oct 20, 2016

#346 in Cargo plugins

Download history 3/week @ 2023-08-08 16/week @ 2023-08-15 19/week @ 2023-08-22 21/week @ 2023-08-29 20/week @ 2023-09-05 2/week @ 2023-09-12 2/week @ 2023-09-19 6/week @ 2023-09-26 2/week @ 2023-10-03 1/week @ 2023-10-10 1/week @ 2023-10-17 10/week @ 2023-10-24 27/week @ 2023-10-31 5/week @ 2023-11-07 3/week @ 2023-11-14 33/week @ 2023-11-21

74 downloads per month


906 lines


Build StatusCoverage Status

cargo-cacher is a caching server in the same spirit as apt-cacher-ng. The goal is to allow recursive caching of the canonical crates.io index.


To configure your system to use a copy of cargo-cacher, you need to setup a .cargo/config file in your project, or in a containing folder. The contents of that folder should look like:


registry = "http://localhost:8080/index"

replace-with = "mirror"

Once this is in place, your builds will go through the local proxy, and the crates will be pulled down to the local filesystem when they are first requested. The path can be a remote host as long as the path is to /index. To run cargo-cacher, there are several arguments you probably want to use:

    cargo-cacher [FLAGS] [OPTIONS]

    -a, --all        Prefetch entire Cargo index
    -d               Sets the level of debugging information
    -h, --help       Prints help information
    -V, --version    Prints version information

    -g <git>             Upstream git index (Default: https://github.com/rust-lang/crates.io-index.git)
    -i <index>           Path to store the indexes (git and fiels) at (Default: $HOME/.crates)
    -p <port>            Port to listen on (Default: 8080)
    -f <prefetch>        Path with a list of crate_name=version OR lock file to pre-fetch
    -r <refresh>         Refresh rate for the git index (Default: 600)
    -t <threads>         How many threads to use to fetch crates in the background
    -u <upstream>        Upstream Crate source (Default: https://crates.io/api/v1/crates/)

Full mirror

cargo-cacher supports providing a full mirror with the -a flag. Passing this flag will create a background thread pool on startup that will fetch all crates currently in the upstream index.


Prefetch is an option that I feel deserves further attention. Prefetch is a path to a file containing one line per crate/version, example:


The above input will fetch log version 0.3.6 and libc version 0.1.12 before being requested by a user. This happens on a separate thread so the server can continue to start up without waiting on the pre-fetching to complete.


  • Add expiration on background thread
  • Add statistics

If you would like to support me:


~560K SLoC