Skip to content

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

Merged
merged 3 commits into from
Nov 25, 2019
Merged

Added cache control to readme files #1924

merged 3 commits into from
Nov 25, 2019

Conversation

hbina
Copy link
Contributor

@hbina hbina commented Nov 24, 2019

Related issue: #1915

extra_headers parameter is no longer wrapped in Option<T>

`extra_headers` no longer wrapped in Option<T>
@rust-highfive
Copy link

r? @smarnach

(rust_highfive has picked a reviewer for you, use r? to override)

Copy link
Contributor

@smarnach smarnach left a 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.

@@ -137,7 +137,7 @@ fn main() {
content,
content_length,
"text/html",
None,
header::HeaderMap::new(),
Copy link
Contributor

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(),
Copy link
Contributor

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).

Copy link
Contributor Author

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>?

Copy link
Contributor

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.

Copy link
Contributor

@smarnach smarnach left a 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.

@smarnach
Copy link
Contributor

@bors r+

This should be low risk to deploy.

@bors
Copy link
Contributor

bors commented Nov 25, 2019

📌 Commit f82d6e3 has been approved by smarnach

@bors
Copy link
Contributor

bors commented Nov 25, 2019

⌛ Testing commit f82d6e3 with merge f939089...

bors added a commit that referenced this pull request Nov 25, 2019
Added cache control to readme files

Related issue:  #1915

`extra_headers` parameter is no longer wrapped in `Option<T>`
@bors
Copy link
Contributor

bors commented Nov 25, 2019

☀️ Test successful - checks-travis
Approved by: smarnach
Pushing f939089 to master...

@bors bors merged commit f82d6e3 into rust-lang:master Nov 25, 2019
@hbina hbina deleted the add_cache_control_for_readmes branch November 26, 2019 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants