-
Notifications
You must be signed in to change notification settings - Fork 649
Added cache control to readme files #1924
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
Conversation
`extra_headers` no longer wrapped in Option<T>
r? @smarnach (rust_highfive has picked a reviewer for you, use r? to override) |
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.
@hbina Thanks for taking this on! I've added a few comments.
src/bin/render-readmes.rs
Outdated
@@ -137,7 +137,7 @@ fn main() { | |||
content, | |||
content_length, | |||
"text/html", | |||
None, | |||
header::HeaderMap::new(), |
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.
Shouldn't we set a TTL here as well?
(For context, this is a binary that re-renders all readme files. It can be manually run if we make updates to the readme rendering code.)
let mut extra_headers = header::HeaderMap::new(); | ||
extra_headers.insert( | ||
header::CACHE_CONTROL, | ||
CACHE_CONTROL_IMMUTABLE.parse().unwrap(), |
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 variable CACHE_CONTROL_IMMUTABLE
is set to public,max-age=31536000,immutable
, i.e. the files are tagged to never change and to live for one year in the cache. However, the readme files might change, so let's cache them only for a week, and let's not tag them as immutable. (You may want to read the documentation of the cache-control header).
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.
I see, sorry for misunderstanding the original Issue. So I assume the only field that is required is max-age=<seconds>
?
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.
I think you can keep public
as well. Not sure whether it has any effect when setting max-age
at the same time, but it certainly doesn't hurt.
Now no longer lasts for a year and removes immutability
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.
@bors r+ This should be low risk to deploy. |
📌 Commit f82d6e3 has been approved by |
Added cache control to readme files Related issue: #1915 `extra_headers` parameter is no longer wrapped in `Option<T>`
☀️ Test successful - checks-travis |
Related issue: #1915
extra_headers
parameter is no longer wrapped inOption<T>