Understanding why so many HEAD requests when dependencies are cached

In Jenkins we build with a fresh container.

We use artifactory but even with a fast network 1000’s of dependencies can be slow.

As a workaround we built our container image with a .gradle folder containing all/most of the dependencies in the cache.

This mostly worked. Builds show that the dependencies are no longer downloaded and it is faster. However, when doing a build scan, under the network tab I can see that it issued >1000 HEAD requests. I read that it uses a HEAD request to verify the artifact hasn’t changed.

The question is: why does it think it needs to check if the artifact hasn’t changed though? It found the files in the gradle cache, and I’m using the same build scripts. And is there a way to tell it not to? I’m looking for any possibilities. I can try to put some code together but hoping we can solve it theoretically without that, since it’s a work project. Oh I can confirm none of these are “changing” or dynamic versions. It looks like a HEAD request for every dependency.

Thanks!