Nexus caching not working


I’m new to nexus and is using NRM OSS 3.20.1-01.

Requirement :
We have maven,p2,raw,npm repos. We need to have local cache of all respective upstream remote repos which are proxied to our local nexus.
Cache should last for 15days (example), and cache should be updated every day for newer artifacts at remote repo.

Issue : Artifacts not available from cache regardless some standard settings to cache those from upstream repo.

Current settings :
negativeCache: 0 # Disregards the negative reply and try fetching from upstream for every call.
contentMaxAge: 1440.0 # refresh artifacts daily

No cleanup policies are configured.

Can some one please shed some light on what I’m missing here to fulfill the requirement ?

Nexus Repository Manager does not fetch all dependencies from the remote repository (not all repositories would even support that and it would potentially use a lot of disk space to do so). Rather the proxy will download items from the remote upon request. So if nobody asks for a package from the remote it won’t be in the proxy. The proxy logic will automatically check for updates to cached packages. So the only way to get items cached by the repository manager will be to have something that pulls items through the proxy. I wouldn’t recommend doing that in an automated fashion though as you’ll lose the ability to see where the initial request came from.

1 Like

Thank you for the response. However, the artifacts in the upstream remote repo are being probed by our build applications whenever required. Even then those regularly used artifacts are not cached in our local nexus.

Since the cache is not working in our local nexus, whenever the upstream remote repo is unavailable our build application throws error as artifacts unavailable.

Ah, I think I understand the problem you are having now. I think you should try setting both the contentMaxAge and metadataMaxAge to 0. That should ensure that fresh metadata is fetched from the remote on all requests instead of using a cached version. Many formats will tell the client if something exists or not solely based on the metadata and not by trying to download the artifact directly. Assuming that setting works, you will probably want to put some thought into a small, but non-zero age to avoid every request to nexus having to reach out to the remote.