Does a remote cache slow your build when it misses?
You may worry that asking a remote cache first makes every build slower when nothing is cached yet. With FosterStack Cache, a server you run yourself, a miss added about one second to a 17.5-second build on a GitHub-hosted CI machine, and a hit saved about four.
The short answer
- A miss costs little. With an empty cache the build took about one second longer than with no cache at all, about 6%. The miss build was slower in 6 of 7 rounds.
- A hit saves time. With the cache filled, the same build took about four seconds less, about 24% less.
- We did not test a project with more skipped work. Our test project compiles quickly and every build also paid Gradle's start-up, so these percentages may differ on a bigger project.
What to do
Our advice, not a test result: turn the remote cache on in CI first. With the server on the same machine, as in our test, cold builds cost little and warm builds are faster. To set it up, see your first 15 minutes with a self-hosted build cache. To let CI fill the cache and laptops only read it, see let CI write, developers only read.
How we checked
We ran the same Gradle build three ways, seven times each, and timed the whole command.
| Setup | Fastest | Median | Slowest |
|---|---|---|---|
| No remote cache | 17.06 s | 17.54 s | 18.17 s |
| Remote cache, empty (a miss) | 16.83 s | 18.54 s | 18.67 s |
| Remote cache, filled (a hit) | 12.79 s | 13.41 s | 13.60 s |
Where: a GitHub-hosted CI machine, Ubuntu 24 image 20261004.327.1, 4 vCPUs (AMD EPYC 7763), 16 GB. The run and its log are public, and the script is bin/bench-miss-cost.sh.
What: Gradle 9.8.0, Java 21.0.12.1, FosterStack Cache 0.2.1. The project had 4 modules of 150 generated classes each, and only the compile tasks ran.
How: the three setups ran in turn, seven times, after one warm-up round that was dropped. Every build used a fresh copy of the project, a new empty Gradle home and no Gradle daemon, so each one includes Gradle's start-up and the compile of its build scripts. Gradle's local cache was off.
Limits: the cache server ran on the same machine, so there was no network delay. Over a real network every lookup also costs a round trip, and a miss would likely cost more than shown. Not tested: Maven, other project sizes, other machines, tests and jars, a real network.