-
Notifications
You must be signed in to change notification settings - Fork 642
static.crates.io cache control #1826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This would also allow Cloudfront to store crates for a longer time, so it may speed up some downloads in some parts of the world. |
This definitely sounds like it's worth doing, but updating old crates basically requires a script to go through and tell AWS to copy the file to itself overriding metadata -- which is fairly manual and I'll want to spot check a few dozen times as running that is relatively high risk. That said, I'd be happy to see a pull request which added this header to all new publishes |
This should be safe to add to new publishes now, but I think we will need to make sure we've cleaned up any other issues with the headers before applying this to all old crates. The main thing I remember is any remaining crates with |
I've done a quick consistency check for the headers Cloudfront currently serves for all crate versions: So only five crates in total have any kind of deviation in their headers. (For two crates, all versions weirdly have the content type It should be possible to update all crates in one go by using the AWS web console for the update. The steps should be
This updates the selected headers recursively for all crate files, and does not touch any other headers or permissions. It's also possible to do the same thing with a single invocation of the I believe performing the above steps would both fix all remaining issues with the current metadata and set the Cache-Control header, though we probably want to do this in separate steps to be a bit more conservative. I manually tested this in my private AWS account. |
@pietroalbini I'm not sure we want to set the TTL for CloudFront distributions as you did in the simpleinfra repo. This has several downsides:
So I'd prefer if we can simple leave the TTL at its default, and leave it up to the uploading code to set reasonable headers. we can then go ahead with #1871, even though we would still need to update all existing objects in S3. |
@smarnach good point, changed the terraform configuration to leave default TTLs for static. |
@pietroalbini Thanks, looks good to me! This also solves the issues with readme files mentioned in the last meeting (specifically that we shouldn't cache them for ten years, since we may want to regenerate them). |
Crate files on static.crates.io don't have any explicit cache lifetime set. Please consider adding caching information, such as
Cache-control: max-age=31536000, immutable
.Even though Cargo itself has a non-HTTP cache and doesn't use that information, it would be helpful for users who put a caching proxy in front of crates.io infrastructure.
curl -I 'https://static.crates.io/crates/winapi/winapi-0.2.5.crate'
The text was updated successfully, but these errors were encountered: