Why does a proxy repository recheck cached metadata, such as a Maven version list, much sooner than the artifact files it caches?
answer
- one changes, one does not
- immutable versions, mutable lists
- two timers in the proxy settings
- new version invisible until expiry
basics
~20 sA released artifact file is expected never to change, so its cached copy stays valid; metadata such as maven-metadata.xml or an npm packument changes every time the upstream publishes, so the proxy must refresh it to see new versions.
solid answer
~50 sA proxy repository caches two different things. **Artifact files** (a JAR, a tarball, a wheel, an image layer) sit at a path naming a released version that is expected never to change, so a cached copy stays correct. **Metadata** (`maven-metadata.xml` with its `<versions>` and `<lastUpdated>`, an npm packument with its `dist-tags`, a PyPI simple index page, the manifest a container tag points to) is rewritten whenever the upstream publishes. So products give metadata its own, shorter timer. Artifactory's *Metadata Retrieval Cache Period* defaults to 7,200 seconds, and 21,600 for Docker, OCI and Helm OCI remote repositories, and does not affect most artifacts; Nexus Repository has separate *Maximum Component Age* and *Maximum Metadata Age* settings, in minutes. The tradeoff is freshness against upstream traffic: a new upstream version stays invisible through the proxy until the cached metadata expires.
code
xml · 13 lines<metadata>
<groupId>org.example</groupId>
<artifactId>payments-client</artifactId>
<versioning>
<latest>2.5.0</latest>
<release>2.5.0</release>
<versions>
<version>2.4.1</version>
<version>2.5.0</version>
</versions>
<lastUpdated>20261009081500</lastUpdated>
</versioning>
</metadata>go deeper
Recall that a proxy caches both package files and the metadata listing versions, and that the metadata is what must be refreshed for new versions to appear.
Explain why released files are safe to keep while version lists go stale, and name each product's two settings: Artifactory's metadata retrieval period, Nexus Repository's component and metadata ages.
Diagnose a version that is published but invisible through the proxy by comparing upstream and proxied metadata, then refresh it with a path-scoped zap rather than lowering the period globally.
Set metadata periods per upstream and format from how fast teams need new versions versus how much upstream load and outage exposure the organisation accepts.
## Two kinds of cached content A **proxy repository** keeps local copies of what builds request from a public registry. Those copies fall into two groups that age very differently. - **Artifact files** are the packages themselves: a JAR and its POM, an npm tarball, a wheel, a container image layer. Each sits at a path that names one released version. Public registries expect a released version never to change, so once the proxy holds the file, its copy is expected to stay correct. - **Metadata** is the set of documents that say *what exists*: the artifact-level `maven-metadata.xml` with `<latest>`, `<release>`, `<versions>` and `<lastUpdated>`; the npm packument listing every version and the `dist-tags` such as `latest`; a PyPI simple index page; the manifest a container tag currently points to. These are rewritten every time someone publishes. If the proxy treated both the same way, it would either recheck immutable files for nothing or serve version lists that never learn about new releases. ## What happens when a version is published upstream 1. A build resolves a library through the proxy, which caches `maven-metadata.xml` listing 2.4.1 and 2.5.0, plus the 2.5.0 JAR. 2. Upstream, 2.6.0 is published. The upstream metadata now lists three versions. 3. Until the proxy's metadata cache period expires, every build reading through the proxy still sees two versions. A request for "the newest release" resolves 2.5.0. 4. When the period expires, the next metadata request goes upstream, the list gains 2.6.0, and builds see it. 5. The 2.5.0 JAR was never rechecked in any of this, and did not need to be. ## The settings in two products | | Artifactory remote repository | Nexus Repository proxy repository | |---|---|---| | Metadata timer | *Metadata Retrieval Cache Period*, in seconds | *Maximum Metadata Age*, in minutes | | Default | 7,200 s for most types; 21,600 s for Docker, OCI and Helm OCI | not stated on the page | | Artifact timer | most downloaded artifacts are not affected by the metadata period | *Maximum Component Age*, in minutes | | Floor | 30 seconds minimum | not stated on the page | Artifactory's documentation names the files the metadata period governs: `maven-metadata.xml`, npm's `package.json` (the packument) and a Docker `manifest.json`. Nexus Repository's documentation adds that it uses the greater of the two age values before rechecking the remote repository, so read its two settings together rather than as independent timers. ## Choosing the period - **Shorter** means new upstream versions appear sooner, but more requests reach the public registry, builds wait on its latency more often, and an upstream slowdown reaches every build sooner. - **Longer** means fewer upstream calls and more tolerance of upstream trouble, but teams wait longer to see a version they were told is out. - **Format matters.** A mutable container tag is metadata too, and Artifactory ships a longer default for Docker, OCI and Helm OCI remote repositories, so the right number depends on the format, not on one global value. - **Upstream type matters.** A remote repository pointing at another internal instance that publishes many times a day may justify a short period that a public registry does not. ## Diagnosing a version that is out but not visible - Fetch the metadata through the proxy and directly from the upstream, and compare the version lists and `<lastUpdated>`. - If the upstream lists the version and the proxy does not, the proxy's metadata is stale: wait for expiry or refresh that path. - If the exact file returns `404` through the proxy while the upstream serves it, look at the proxy's not-found cache instead, which is a separate setting with its own period. ## Refreshing on purpose When a team needs a new version before the period expires, Artifactory offers a **zap**. Zapping invalidates cached metadata so each item is re-fetched on its next request; it deletes no files and does not invalidate immutable binaries. A path-scoped zap, `POST api/zap/{repoKey}/{path}`, limits the effect to the affected packages, which matters on large repositories where a full zap can take many minutes. If the upstream is unavailable when the item is next requested, the stale copy is served, so verify the refresh succeeded. ## Common misconceptions - "Every cached file expires on the same timer." Metadata and artifacts have separate settings for a reason. - "A missing new version means the artifact file is missing upstream." Usually the proxy's version list is simply stale. - "A minimal metadata period is free." It moves load and latency onto every build.
- What does zapping an Artifactory remote repository's cache actually do?It marks cached metadata as expired so each item is re-fetched from the upstream on its next request. It deletes no files and leaves immutable binaries alone. A path-scoped zap, `POST api/zap/{repoKey}/{path}`, limits it to the affected packages. If the upstream is unreachable when an item is next requested, the previous copy is served, so check that the refresh succeeded.
- What does a very short metadata cache period cost?Every expiry turns a cache hit into an upstream round trip, so metadata requests reach the public registry far more often, builds wait on its latency, and an upstream slowdown reaches every build sooner. Artifactory enforces a 30-second floor. Short periods suit an upstream whose new versions a team must see quickly, such as another internal instance; public registries rarely need one.
- A proxy refreshes every cached file on one timer, artifacts and metadata alike.
- If a build cannot see a new version, the artifact must be missing upstream.
- Setting the metadata period to its minimum has no cost.
- Zapping an Artifactory remote repository deletes the cached files.