Local Dependecy Cache Grows Too Big

We found many copies of the same artifact with the same version in local depency cache.

This is the situation: We have several projects that share common library developed in house. Common library is published to our local Ivy repository, projects have dependency directed to this repository. Common library is changed very often so we use snapshot mechanism (dependency isChanging and configuration has resolutionStrategy { cacheChangingModulesFor(0, “seconds”) }).
Everything works fine, but the local dependcy cache grows a lot on the build server.
What happens is that when a project is first build a copy of artifact file from common library appears in local cache on build server (in jenkins/.gradle/caches/modules-2/files-2.1). Then the common library is changed and published again under the same name and version. Next time a project is build, it gets correctly changed artifact file of the common library and this new file appears in local cache on build server, but the old one is still there.

The cache then grows a lot and we run out of disk.

In this documentation https://docs.gradle.org/current/userguide/dependency_resolution.html#sub:cache_cleanup I found:

Cache Cleanup
Gradle keeps track of which artifacts in the dependency cache are accessed. Using this information, the cache is periodically (at most every 24 hours) scanned for artifacts that have not been used for more than 30 days. Obsolete artifacts are then deleted to ensure the cache does not grow indefinitely.

I have two questions:

  1. Is there a way to shorten this no-access time, to make cached artifacts obsolete sooner (to make it less then 30 days)?
  2. If a new artifact file is stored to local cache (with the same modul, name and version), is the previous file still needed? Shouldn’t be deleted immediatelly?