How to cache only certain artifacts from a remote repository?
Currently, remote repositories can either be configured to locally cache everything that is resolved from the remote repository or to not cache anything.
This article will provide two solutions two achieve caching of only specific artifacts.
2) Create two different remote repositories pointing to the same remote URL, one (let’s call it repoA) with caching enabled and an exclude pattern to exclude the artifacts you do not want to cache locally, the other (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, 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.