How do I cache only certain artifacts from a remote repository?

If you are looking to cache only certain artifacts from a remote repository, this is possible, but the functionality is not built into Artifactory. Currently, remote repositories can either be configured to locally cache everything that is resolved from the remote repository, or to not cache anything. However, this can be done with a user plugin, by using the beforeCreate entry point to cancel the creation of a binary to the local cache if it does not match a predefined pattern. You can always check our current plugins to see if it already exists. A list of our currently provided user plugins can be found here.


Another option would be creating two different remote repositories pointing to the same remote URL. The first (let’s call it repoA) with caching enabled and an exclude pattern to exclude the artifacts you do not want to cache locally, the second (repoB) without an exclude/include pattern and without caching artifacts.

Both remote repositories should be aggregated in one virtual repository where the order of the repositories is repoA before repoB. This is so when a client tries to resolve from this virtual repository, Artifactory will first try to resolve from repoA if the artifact is not excluded it will be resolved and cached. If the file is excluded from this repository, Artifactory will resolve it from repoB and not cache it locally.