simpleinfra icon indicating copy to clipboard operation
simpleinfra copied to clipboard

Enable Brotli in CloudFront settings for docs.rust-lang.org

Open jsha opened this issue 4 years ago • 3 comments

(Moving from https://github.com/rust-lang/rust/issues/82286)

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

jsha avatar Feb 20 '21 23:02 jsha

Based on a bit of digging it looks like we'll need to switch to the new policies to do this (vs. legacy caching) on the relevant endpoints. It does seem like a good win!

Mark-Simulacrum avatar Feb 20 '21 23:02 Mark-Simulacrum

Also I should mention: .woff, .woff2, and .png files should be excluded since they are already compressed. There's a good chance CloudFront's config is smart enough to do this already, but worth checking.

jsha avatar Feb 28 '21 01:02 jsha

Bump on this?

jsha avatar Sep 30 '21 02:09 jsha