Skip to content

storage: Add CDN cache-tag metadata on uploads#14075

Merged
Turbo87 merged 3 commits into
rust-lang:mainfrom
Turbo87:cache-tags-uploads
Jun 28, 2026
Merged

storage: Add CDN cache-tag metadata on uploads#14075
Turbo87 merged 3 commits into
rust-lang:mainfrom
Turbo87:cache-tags-uploads

Conversation

@Turbo87

@Turbo87 Turbo87 commented Jun 26, 2026

Copy link
Copy Markdown
Member

This PR adds CDN cache-tag metadata to newly uploaded static.crates.io objects.

StorageKey::cache_tags() returns the tag string for taggable objects:

  • .crate, .zip, .zip.json, and readme objects carry both crate:{name} and release:{name}@{version}
  • the OG image and per-crate feed carry only crate:{name}
  • global objects (site-wide feeds, db-dumps) stay untagged

attributes() emits the tags as the x-amz-meta-cache-tags user-metadata header, which CloudFront and Fastly will read at cache-fill time to index each object under its tags (requires further changes in the simpleinfra repo).

This is additive and changes no existing behavior. New objects gain the metadata and nothing consumes the tags yet. The local-filesystem dev backend continues to no-op attributes, so only S3 and the in-memory test backend carry it.

@Turbo87 Turbo87 requested a review from a team June 26, 2026 10:46
@Turbo87 Turbo87 added the C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works label Jun 26, 2026
@Turbo87 Turbo87 force-pushed the cache-tags-uploads branch from 096c430 to 22cee7a Compare June 27, 2026 19:51
@rustbot

This comment has been minimized.

Turbo87 added 2 commits June 28, 2026 09:56
This returns the comma-separated CDN cache tag string for taggable
objects. Version-scoped objects (`.crate`, `.zip`, `.zip.json`, readme)
carry both a `crate:{name}` and a `release:{name}@{version}` tag.
Crate-scoped objects (OG image, per-crate feed) carry only `crate:{name}`.
Global objects stay untagged and rely on URL purge. Names and versions
are used verbatim, with no normalization.
This wires `cache_tags()` into `attributes()`, so every taggable upload
carries an `x-amz-meta-cache-tags` entry. The S3 backend surfaces that
header for the CDNs to read at cache-fill time, while the local-filesystem
dev backend keeps no-oping attributes. Untagged global objects stay
metadata-free.
@Turbo87 Turbo87 force-pushed the cache-tags-uploads branch from 22cee7a to ccf5f33 Compare June 28, 2026 07:56
@rustbot

rustbot commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Turbo87 Turbo87 force-pushed the cache-tags-uploads branch from ccf5f33 to 6d3f88a Compare June 28, 2026 08:18
@Turbo87

Turbo87 commented Jun 28, 2026

Copy link
Copy Markdown
Member Author

I've added a feature flag so that we can test this out on staging without blocking production deploys in the meantime.

@Turbo87 Turbo87 merged commit 33caffc into rust-lang:main Jun 28, 2026
12 checks passed
@Turbo87 Turbo87 deleted the cache-tags-uploads branch June 28, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-backend ⚙️ C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants