Skip to content
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

doc.rust-lang.org: add caching headers for static content #82286

Closed
jsha opened this issue Feb 19, 2021 · 3 comments
Closed

doc.rust-lang.org: add caching headers for static content #82286

jsha opened this issue Feb 19, 2021 · 3 comments

Comments

@jsha
Copy link
Contributor

jsha commented Feb 19, 2021

Steps to reproduce:

  1. Load any doc.rust-lang.org page, e.g. https://doc.rust-lang.org/std/str/index.html.
  2. Open Developer Console.
  3. Click the URL bar and hit enter to load the page again.

Expected result:

Most resources are cached and do not hit the network.

Actual result:

Many objects require a network fetch, but get a 304 Not Modified. These should be served with long caching headers.

image

Current headers:

$ curl -I https://doc.rust-lang.org/SourceCodePro-Regular.woff
HTTP/2 200 
content-type: font/woff
content-length: 55472
last-modified: Thu, 11 Feb 2021 14:27:46 GMT
x-amz-version-id: R.xOjlR7eKEsQwzm9EIrHs9eeCIDeXYq
server: AmazonS3
date: Thu, 18 Feb 2021 13:27:31 GMT
etag: "957fa8c030f8116bea59c13df470e4e8"
x-cache: Hit from cloudfront
via: 1.1 4b84530d7a095b58fb7a1d20b7f0cbe0.cloudfront.net (CloudFront)
x-amz-cf-pop: HIO50-C2
x-amz-cf-id: QpMYsW6BVcTPpDmi8Pg9HiMz_1iSOIpdYv60MMzNqVoV707yqsv_Dw==
age: 63023
@jsha
Copy link
Contributor Author

jsha commented Feb 19, 2021

Adding a separate topic here because it's closely related: We can achieve a significant decrease in file size by enabling Brotli compression, which is an option in CloudFront: https://aws.amazon.com/about-aws/whats-new/2020/09/cloudfront-brotli-compression/

Brotli has been supported in major browsers since 2016: https://en.wikipedia.org/wiki/Brotli

search-index1.50.0.js is currently served as 272,247 gzip bytes, but it could be served as 140,170 brotli bytes.

$ curl https://doc.rust-lang.org/search-index1.50.0.js --header "Accept-Encoding: gzip" -o search-index.js.gz
$ zcat search-index.js.gz | brotli > search-index.js.br
$ ls -l search-index.js.*
-rw-rw-r-- 1 jsha jsha 140170 Feb 18 23:56 search-index.js.br
-rw-rw-r-- 1 jsha jsha 272247 Feb 18 23:56 search-index.js.gz

@tesuji
Copy link
Contributor

tesuji commented Feb 19, 2021

Brotli has been supported in major browsers since 2016: https://en.wikipedia.org/wiki/Brotli

Per https://caniuse.com/brotli, IE browser doesn't support this header. But since it's just a header, I don't think any incompatibility problems here with IE. However, changing the header shall be done by rust-infra/docs.rs team, not rustdoc it self as rustdoc have to serve pages from local files.

@jsha
Copy link
Contributor Author

jsha commented Feb 20, 2021

Opened issues on rust-lang/simpleinfra instead, so closing this. Thanks for the guidance!

@jsha jsha closed this as completed Feb 20, 2021
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

No branches or pull requests

2 participants