Does the build cache survive a restart? A real test
You restart the cache server, or it crashes, or the container is replaced. Do your stored build results come back? We tested a clean stop, a forced kill and a wrong data folder with FosterStack Cache 0.2.1 and a real Gradle build.
The short answer
- After a clean stop and start on the same data folder, every result was still there.
- After the server was killed with
kill -9and started again on the same folder, every result was still there. - On a different, empty data folder, the cache was empty and the next build rebuilt everything.
The results live in the data folder, not in the running server. If that folder survives, your cache survives.
What we ran
A four-module Gradle 9.8.0 project (the one from Gradle build cache for a monorepo) against a server set up with FSCACHE_DATA_DIR pointing at a folder. Every build used a fresh copy of the project and an empty Gradle home, so the only shared thing was the server. Our first run used a project folder that still held build output from an earlier check; we repeated all four steps from a clean copy and got the same results. All four builds ended with BUILD SUCCESSFUL. "From cache" counts the four compileJava tasks that printed FROM-CACHE.
| Step | Server state before the build | Entries in the status page | From cache |
|---|---|---|---|
| 1. First build | New, empty data folder A | 0, then 13 afterwards | 0 of 4 |
| 2. Clean restart | Stopped normally, started on folder A | 13 (same as before) | 4 of 4 |
| 3. Crash | Killed with kill -9, started on folder A | 13 (same as before) | 4 of 4 |
| 4. Wrong folder | Started on a different empty folder B | 0 | 0 of 4 |
The status page is the server's /statusz address. It showed the same 13 entries and the same size in bytes right after each restart, before any build ran.
One limit of this test
We killed the server while it was idle. We did not kill it in the middle of an upload, so this page says nothing about a half-written result. What we can say is that a crash with nothing in flight lost nothing.
If your cache comes back empty
An empty cache after a restart means the server is looking at a different folder than before. It is the same as step 4. Check that the data folder or volume is still the one you expect:
- Docker: use a named volume or a mounted folder for the data directory. See Gradle build cache with Docker Compose.
- Kubernetes: the data directory needs a persistent volume claim. See Gradle build cache on Kubernetes.
- Permissions: if the server cannot write to the folder, see permission denied on the data directory.
To copy the data somewhere safe, or to move it to another server, see back up and restore.
Run on FosterStack Cache 0.2.1 (macOS, arm64) with Gradle 9.8.0, Java 27.