How Remote Repository Metadata works

AuthorFullName__c
Patrick Russell
articleNumber
000004530
FirstPublishedDate
2019-08-23T07:13:48Z
lastModifiedDate
2025-05-15

How Remote Repository Metadata works

Offline backups of remote caches
Artifactory has a great set of remote repository types available for use with practically any package manager. The system underlying this proxying mechanism is actually quite complex. The main problem is how to handle upstream metadata. Normally, Artifactory's remote repository system relies on the client making the correct requests. This is how the generic remote repository functions (i.e., the downstream client must make a correct GET request to download a given remote package).

For other package types, the clients are more sophisticated and require special care. Each package manager type uses a metadata system to determine which packages and dependencies to download. Some examples include Maven's maven-metadata.xml file, PyPI's simple.html file, and YUM's repodata/* files. As the syntax for all of these package managers are unique, Artifactory has had to solve each complex metadata system.
 
Metadata Retrieval Cache Period
This setting can be found by navigating to Admin > Repositories > Remote > < Remote-repo > Advanced menu in both Artifactory 6.X and 7.X.

The Metadata Retrieval Cache Period (MRCP) option, the definition reads: "This value refers to the number of seconds to cache metadata files before checking for newer versions on remote server. A value of 0 indicates no caching." This setting affects each repository type differently. For example, in Maven repositories, it causes Artifactory to check for new maven-metadata.xml files every 600 seconds. In PyPI, the simple.html file is updated using the same timestamp.

Accordingly, Artifactory doesn't need to read individual metadata files. It just passes along fresh metadata to the client, the client then does the processing to make its next requests.

Using PyPI as an example, the sequence looks as follows:

User-added image 

1. A user runs a pip install against Artifactory

    a. The pip client requests the artifactory.com/artifactory/api/pypi/pypi-remote/simple HTML page

    b. Artifactory's Metadata Cache Retrieval Period has expired, so it serves an updated HTML page.
        There's a slight delay as it has to re-download the file. If the MCRP has not expired, the cached file is sent instead.

2. Based on the simple HTML metadata, the pip client requests the desired package binaries

    a. Artifactory sends the file from its remote cache to the client, pypi.org is skipped here.

However, this can present a problem. For example, consider the possibility of a developer uploading a package to a remote site. What would happen if they tried to download it through Artifactory right after the upload?

In this example situation, the package won't be present in Artifactory's copy of the metadata and the developer would receive a 404 Not Found error.

The solution to this problem is built into the Artifactory UI. The Zap Cache function resets the MCRP for the whole remote, thus assuring that fresh metadata is sent to the client after the Zap:

User-added image 
This setting can be tuned to improve download performance.

Users who always need accurate, up-to-date metadata should lower the setting, possibly to "0" to disable it. This will slow down most pulls (as Artifactory will constantly be serving fresh metadata), but ensure that the most accurate data is always being used.

Of course, users concerned about performance should increase this setting instead. Be aware, however, that doing so will mean that Artifactory will be using its cache more often than not, and at the cost of accuracy. 
Deleted packages and Artifactory's Cache
Up to this point, we've been talking about remote uploads, but what if a remote repository deletes a package? Say a given binary was cached in Artifactory before it was removed upstream, shouldn't it still be available to download? The answer is actually: No, because Artifactory is trying to mirror the remote site, the binary's metadata is being served directly from the upstream source. If the metadata says a particular package has been deleted, the client will receive a 404 Not Found error.

This said, the package hasn't truly been lost! To undelete a given package, it can be copied to a local Artifactory repository. There, Artifactory's local metadata calculation will list the package as available for download. However, as it is tedious to have to go to your UI and manually copy packages just to start using them again, we recommend that you:
  • For Self-Hosted deployments: Install the Workers service on your JFrog Platform.

    • For Cloud deployments: From Artifactory 7.94, the Workers service is supported with Enterprise X and Enterprise+ licenses.

  • Install the JFrog CLI and connect it to your Artifactory instance. See Connecting JFrog CLI to Your JFrog Workers for setup instructions.

  • Deploy the Remote Backup Worker from the JFrog Workers sample repository. This worker automatically copies files from a remote cache to a local backup repository.

  • Create a local Artifactory repository of the same package type as the remote to serve as the backup destination.

  • Configure the worker payload with your repository mappings:

{
    "backups": {
        "repo-foo-remote-cache": "repo-foo-backup-local",
        "repo-bar-remote-cache": "repo-bar-backup-local"
    },
    "dryRun": false,
    "maxDepth": 10,
    "maxFiles": 1000
}
  • Create a virtual repository and have remote clients use its URL instead.

Note: There is also a legacy alternative: downloading and installing Artifactory's Remote Backup User Plugin (which requires a JSON configuration file to be present in order to function as intended). This approach is not recommended and has been superseded by the Workers-based solution described above.

With this system, any file that has been deleted on the remote site will be copied to the local repository and its metadata will be seamlessly merged with the remote's metadata.

Note: There are usually good reasons for deleting certain packages. Accordingly, there may be some risk in continuing to use a particular deprecated package. Additionally, package overwrites will never appear to the download client, as old local files will be served first.