fastly: Cache crates.io webapp responses per origin headers#1067
Merged
Conversation
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.
Member
|
applied in staging, let me know how testing goes |
Member
Author
this is what I'm now seeing for our static assets, while the regular API responses are still |
Member
|
should I deploy to prod? |
Member
Author
|
yes, please |
Member
|
done! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The webapp Fastly service ran
return(pass)invcl_recvfor 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 setCache-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 = 0stays, so responses without caching headers and per-userno-storeresponses are still not cached.Created with the help of Claude Code, which:
return(pass)by inspecting Fastly vs CloudFront headers,