-
Notifications
You must be signed in to change notification settings - Fork 198
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
invalidate CDN caches after build #1825
invalidate CDN caches after build #1825
Conversation
@jsha this could be the next step, what do you think? |
Without having read the source yet, I like the plan. One caveat: for correctness, it would be ideal if we could prevent caching of In other words, we should cache the static JS, CSS, and images (already done, for a long time). And we should cache the HTML (this PR). But we shouldn't cache invocation specific JS files, because then a fresh HTML page could get a browser-cached invocation specific JS file, and produce inconsistent/surprising behavior. As a concrete example, assuming invocation specific JS is cached:
There are ways to solve this in rustdoc, for instance by mixing crate version into the filename for invocation specific files. But for now I think we should consider invocation specific JS files under The performance impact of not caching these should be pretty low, since they are not on the critical path for page load (at least in current rustdoc). |
@jsha perhaps I'm missing something, but if this would be an problem, wouldn't it already be an problem? Since the resource suffix includes the nightly version (for example: I also remember a discussion about this, if needed I can try to find the issue. If we want to optimize this, one other option is to only use |
Oh! I didn't think to look before, but yes, it looks like invocation-specific files (like https://docs.rs/rustls/latest/rustls/sidebar-items-20220517-1.63.0-nightly-4c5f6e627.js) currently get the So, no need to address the problem I mentioned in this PR. Thanks for checking. |
Aha, here's the issue from January: #1593 |
I'll add some more tests , but I would love some feedback around the general idea here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach looks great!
@jsha this is ready for another round, also cc @Nemo157 I'm not 100% certain about the cdn-backend design, I'm happy to take other ideas that make testing it in the builder possible :) I removed purging only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we already have a tokio runtime stored somewhere? Why do we need another?
valid concern! We had another in the S3 storage backend. In this PR I'm moving the runtime to the context, and the S3 backend will also use the same. |
ping @jsha @rust-lang/docs-rs anyone got time for reviewing? Thinking longer about #1552 (comment) I can imagine also Otherwise the default TTL option with |
@Nemo157 I added the requested changes |
while working on #1552 (comment) I came to the conclusion that I want a different structure for defining the caching headers, so I'll remove it from this PR and will create a new one for this. So the main piece remaining here is the CDN invalidation after build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just noticed a tiny test simplification
0b4ed16
to
3df6127
Compare
This is a follow-up to #1569 and is working towards #1552.
This adds CloudFront invalidation after releases for just invalidating the whole
/crate/*
prefix after each build.without any settings it won't do anything.
To keep in mind when reviewing: CloudFront invalidations can be relatively slow, up to 10-15 minutes. I'm not sure if the time depends on the amount of paths / patterns in the request, or the amount of files matching that pattern. My tests were much faster (1 minute max)
original description
This is a follow-up to #1569 and enables us to control caching for
/latest/
pages too.Similarly to versioned pages we can define a normal
max-age
, combined withstale-while-revalidate
.This also adds CloudFront invalidation after releases. For now the invalidation choices we have are:
/krate/*
prefix/krate/latest/*
prefix.without any settings it won't do anything, so we can slowly increase caching times and watch what happens.
To keep in mind when we play around with the settings: CloudFront invalidations can be relatively slow, up to 10-15 minutes. I'm not sure if the time depends on the amount of paths / patterns in the request, or the amount of files matching that pattern.