Skip to content

Artifact Cache

The artifact cache keeps the container images and packages your teams download on a volume you own. The next request for the same artifact is answered from that volume instead of the upstream registry, which saves bandwidth and keeps cached packages installable while the registry is unreachable.

Package manager → ShieldedStack policy → cache hit, or upstream registry → cache

Every request is decided by your workspace package policies and image policies first. A cached copy is never permission to download it: a package or image denied after it was cached is refused like any other, and no workspace can reach the cache without passing its own policy.

  • Package archives and the files fetched with them, for npm, NuGet, Cargo, PyPI, Maven, Go, Pub, RubyGems, Composer and Hex.
  • Container image manifests and layers requested by digest. An image pulled by tag is still resolved by the registry each time; the manifest and layers that tag points to are then served from the cache. Each is kept only if its bytes match the digest it was requested by.
  • Only complete, successful downloads. Partial (range) requests, failed or interrupted transfers, and responses the registry marks no-store or private are not kept.
  • Not Maven -SNAPSHOT versions or Composer development versions, which are republished under the same version.
  • Not package metadata, so new releases, yanks and relists still come from the registry.

Cached content is verified while it streams: every time a file is served, its bytes are checked against the sha256 recorded when it was stored. Most of a large file has reached the client by the time the check completes, so a failed check aborts the transfer before it finishes rather than holding the file back. The client sees a failed download, never a completed one, the bad copy is removed, and the next attempt fetches it from the registry again. Container image manifests are small enough to be checked in full before any of them is sent. If the cache cannot be read or written, downloads go to the registry as they would without it.

A cached download is served without contacting the registry at all, so cached packages, and images pulled by digest, keep installing during a registry outage. An image pulled by tag needs the registry to resolve the tag. For a custom upstream, the proxy reads the registry’s service index once after it starts; a proxy restarted while that registry is down cannot serve it until the registry is back.

A cached version stays available after the registry removes it. The cache does not ask the registry whether a version still exists, and every download renews its idle period, so a version that was unpublished or taken down keeps installing for anything that pins it. What stops it is policy: a version blocked by a deny rule or by the workspace’s vulnerability policy is refused whether or not it is cached. Package metadata is never cached, so a removed version disappears from fresh dependency resolution straight away. To drop cached copies outright, empty the cache directory; everything is fetched again on demand.

The cache follows your configured upstreams. Changing a registry’s URL means its artifacts are fetched again from the new source rather than served from the old one. Each download is cached under the exact URL the package manager requested, so a registry whose download links carry a signature that changes on every request is cached once per link.

Every proxy replica and the worker share one cache volume, which must support ReadWriteMany (NFS, CephFS, Azure Files, EFS and similar). The proxies serve and store entries; the worker trims the cache.

Give the cache a volume of its own, or set a size cap. Without a cap the worker reads how full the volume is and treats all of it as the cache’s; see Size and retention.

The trial guide covers turning the cache on and its settings for Docker Compose, and the Helm chart README covers Kubernetes.

The cache is sized in one of two ways.

  • Without a size cap, the cache owns its volume. The worker checks the volume once a minute without scanning files. Above 90% use it scans and evicts older artifacts, targeting 80%. Anything else stored on that filesystem counts against the cache, so use this only for a dedicated volume.
  • With a size cap, the cap is the only budget. How full the volume is no longer matters. Once an hour the worker measures the cache and, above 90% of the cap, evicts older artifacts, targeting 80%. Use this when the cache shares a filesystem, such as an NFS export without a quota or a Docker volume on the host’s disk.

Once an hour the worker also removes artifacts that have gone unused for the idle period, 30 days by default, along with stalled temporary writes.

Artifacts used within the last hour are never removed, even if the idle period is shorter, and a download in progress keeps its artifact in use. On NFS, a download that races a removal, or stalls for more than an hour, may still need a retry.

The hourly measurement for the cap covers stored artifacts and temporary writes, including recently used ones. Metadata and filesystem overhead are excluded. The cap is a best-effort target, enforced once an hour, so leave headroom for an hour of downloads, and expect eviction to fall short while recently used files occupy the space. Shortfalls are logged. If a download cannot be stored, for example on a full volume, it still reaches the client and the failed write is logged. Backing the volume up is optional: a lost cache only means artifacts are fetched from the registry again.

The proxy reports shieldedstack.proxy.artifact_cache.lookups, counting hit, miss, corrupt and skipped results, and shieldedstack.proxy.artifact_cache.stores, counting stored, discarded and failed writes.

A volume that stops answering does not hold downloads up. Each proxy gives a cache lookup 2 seconds and one chunk of a transfer 10 seconds. After three failures in a row it stops using the cache, logs an error, and serves from the registry as it would without one, counting those requests as skipped. Requests already waiting on the volume at that moment each wait out their own limit. Finishing a large file is not held to the limit: it completes in the background. Every 30 seconds it lets one request try the cache again, and returns to it once the volume answers.

The proxy will not start. Check that it runs in forwarding mode whenever the cache is enabled, and that the directory is writable by the proxy’s user.

Every download is a miss. Confirm that downloads complete, and that the registry does not mark artifacts no-store or private or compress them with Content-Encoding. Snapshot and development versions are never cached.

Lookups are counted as skipped. The proxy has stopped using a volume that was not answering in time; its log has the error. Check the mount on that proxy’s node. The cache comes back into use by itself once the volume responds.

Downloads fail with a truncated transfer. A cached copy failed its sha256 check and was removed. The next attempt fetches it again; repeated failures point at the volume itself.