Skip to content

fastly: Cache crates.io webapp responses per origin headers#1067

Merged
marcoieni merged 1 commit into
rust-lang:masterfrom
Turbo87:fastly-webapp-enable-caching
Jun 3, 2026
Merged

fastly: Cache crates.io webapp responses per origin headers#1067
marcoieni merged 1 commit into
rust-lang:masterfrom
Turbo87:fastly-webapp-enable-caching

Conversation

@Turbo87

@Turbo87 Turbo87 commented Jun 3, 2026

Copy link
Copy Markdown
Member

The webapp Fastly service ran return(pass) in vcl_recv for every request, so it never cached anything. The comment said this was to avoid caching the API, but the same origin (crates-io.herokuapp.com) also serves the SvelteKit frontend, including immutable static assets that set Cache-Control: public, max-age=315360000. Those assets were never cached on the Fastly path, while the CloudFront distribution for the same origin cached them normally.

This removes the blanket pass so Fastly honors the origin's Cache-Control, matching CloudFront. default_ttl = 0 stays, so responses without caching headers and per-user no-store responses are still not cached.


Created with the help of Claude Code, which:

  • traced the missing cache hits to the unconditional return(pass) by inspecting Fastly vs CloudFront headers,
  • reviewed the git history to understand why the snippet was added, and
  • made the VCL change.

The webapp Fastly service ran `return(pass)` in `vcl_recv` for every
request, so it never cached anything. The comment said this was to avoid
caching the API, but the same origin (`crates-io.herokuapp.com`) also
serves the SvelteKit frontend, including immutable static assets that set
`Cache-Control: public, max-age=315360000`. Those assets were never
cached on the Fastly path, while the CloudFront distribution for the same
origin cached them normally.

This removes the blanket pass so Fastly honors the origin's
`Cache-Control`, matching CloudFront. `default_ttl = 0` stays, so
responses without caching headers and per-user `no-store` responses are
still not cached.
@marcoieni

Copy link
Copy Markdown
Member

applied in staging, let me know how testing goes

@Turbo87

Turbo87 commented Jun 3, 2026

Copy link
Copy Markdown
Member Author
x-served-by: cache-fra-eddf8230101-FRA, cache-fra-etou8220020-FRA
x-cache: MISS, HIT
x-cache-hits: 0, 3

this is what I'm now seeing for our static assets, while the regular API responses are still MISS, MISS, as intended 👍

@marcoieni

Copy link
Copy Markdown
Member

should I deploy to prod?

@Turbo87

Turbo87 commented Jun 3, 2026

Copy link
Copy Markdown
Member Author

yes, please

@marcoieni marcoieni merged commit 788e77f into rust-lang:master Jun 3, 2026
4 checks passed
@marcoieni

Copy link
Copy Markdown
Member

done!

@Turbo87 Turbo87 deleted the fastly-webapp-enable-caching branch June 3, 2026 10:54
@Turbo87 Turbo87 moved this to For next meeting in crates.io team meetings Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants