From e76ba88fec57273a169e62bca61e10348e8dbc3e Mon Sep 17 00:00:00 2001 From: FosterStack Admin <317177128+fosterstack-admin@users.noreply.github.com> Date: Thu, 8 Oct 2026 20:20:53 -0400 Subject: [PATCH 1/2] Page: Gradle remote build cache not working --- gradle-remote-cache-not-working/index.html | 138 +++++++++++++++++++++ sitemap.xml | 4 + 2 files changed, 142 insertions(+) create mode 100644 gradle-remote-cache-not-working/index.html diff --git a/gradle-remote-cache-not-working/index.html b/gradle-remote-cache-not-working/index.html new file mode 100644 index 0000000..6144c77 --- /dev/null +++ b/gradle-remote-cache-not-working/index.html @@ -0,0 +1,138 @@ + + + + + +Gradle remote build cache not working: no FROM-CACHE + + + + + + + + +
+ +
Infrastructure worth keeping — and kept patched.
+
+
+

Gradle remote build cache not working: no FROM-CACHE

+

Your build runs, nothing fails, and nothing comes from the remote cache. Gradle treats a broken remote cache as non-fatal, so it fails quietly. Work down this list.

+ +

1. Is the build cache switched on?

+

The buildCache block in settings.gradle(.kts) says where the cache is. It does not turn caching on. Without this line the block does nothing:

+
# gradle.properties
+org.gradle.caching=true
+

Or pass --build-cache on each run. This is the most common cause.

+ +

2. Is the local cache hiding the problem?

+

Gradle's local cache is on by default and gives hits even when the remote is failing. So FROM-CACHE on its own does not prove the remote works. Take the local cache out of the picture and show remote errors:

+
rm -rf ~/.gradle/caches/build-cache-1
+./gradlew --stop
+./gradlew build --build-cache -i
+

Run it twice. The second run is the one that tells you something.

+ +

3. Is the password reaching Gradle?

+

If the server uses a password and Gradle sends none, every request gets a 401, silently. Two things to check:

+ +

To test the server's password directly, a 401 means the credentials are wrong and a 404 means they are right and the key just is not there yet:

+
curl -s -o /dev/null -w '%{http_code}\n' -u gradle:wrong-password \
+  https://cache.example.com/some-key
+ +

4. Is the URL right, and is it HTTPS?

+

Keep the trailing slash on the URL. Gradle adds the cache key straight onto it. Gradle also refuses plain http:// to anything except localhost unless you set isAllowInsecureProtocol = true. Use HTTPS in real deployments, because Gradle sends the password with every request.

+

One trap in test setups: some sample projects run a check that fails any build containing an http:// URL, including the cache URL. That is the check, not the cache.

+ +

5. Is the server seeing requests?

+
curl -s https://cache.example.com/metrics | grep -E 'fscache_cache_(hits|misses)_total'
+

Run a build and run this again. If neither counter moves, the requests are not arriving. If misses move and hits do not, the cache is working and has not been filled yet, or something in the task inputs changes on every build.

+ +

6. Is this client allowed to upload?

+

If you set isPush to false, or only to true on CI, a laptop only reads. Nothing fills the cache until a machine that may upload has run the build.

+ +

Not the same thing: the configuration cache

+

Gradle may suggest enabling its "configuration cache". That is a different, local feature. It has nothing to do with a remote build cache.

+ +
+ Gradle and Maven setup + Questions and answers +
+
+ + + diff --git a/sitemap.xml b/sitemap.xml index 8c1e470..b949e0f 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -16,4 +16,8 @@ weekly 1.0 + + https://fosterstack.com/gradle-remote-cache-not-working/ + 2026-10-08 + From e6d5c5a34eb5523cf79ec412d2b2d0806cc2c37d Mon Sep 17 00:00:00 2001 From: FosterStack Admin <317177128+fosterstack-admin@users.noreply.github.com> Date: Thu, 8 Oct 2026 21:21:51 -0400 Subject: [PATCH 2/2] Plain-HTTP wording: tested on Gradle 9.8.0, localhost name refused, 127.0.0.1 allowed --- gradle-remote-cache-not-working/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle-remote-cache-not-working/index.html b/gradle-remote-cache-not-working/index.html index 6144c77..ddff837 100644 --- a/gradle-remote-cache-not-working/index.html +++ b/gradle-remote-cache-not-working/index.html @@ -105,7 +105,7 @@

3. Is the password reaching Gradle?

https://cache.example.com/some-key

4. Is the URL right, and is it HTTPS?

-

Keep the trailing slash on the URL. Gradle adds the cache key straight onto it. Gradle also refuses plain http:// to anything except localhost unless you set isAllowInsecureProtocol = true. Use HTTPS in real deployments, because Gradle sends the password with every request.

+

Keep the trailing slash on the URL. Gradle adds the cache key straight onto it. Gradle also refuses plain http:// unless you set isAllowInsecureProtocol = true. In our test with Gradle 9.8.0, the address 127.0.0.1 was allowed without it, but the name localhost was refused. Use HTTPS in real deployments, because Gradle sends the password with every request.

One trap in test setups: some sample projects run a check that fails any build containing an http:// URL, including the cache URL. That is the check, not the cache.

5. Is the server seeing requests?