Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vary: Accept-Encoding header for Amazon S3 hosted site

How do I add a Vary: Accept-Encoding header to the files of a static website hosted by Amazon S3?

This is the only thing keeping me from getting a 100/100 score from Google PageSpeed, I'd love to get this solved!

R

like image 615
Rembrant Van Der Mijnsbrugge Avatar asked Feb 16 '23 21:02

Rembrant Van Der Mijnsbrugge


2 Answers

It's not possible to set the Vary-Accept-Encoding header for S3 objects.

like image 132
powpow Avatar answered Feb 24 '23 01:02

powpow


Just to add some perspective, the reason for this is that S3 doesn't currently support on-the-fly compressing, so it's not possible to set this header. If in the future Amazon does add automatic compression, then that header would be set automatically.

With a static site, you're limited to either:

  1. Serving uncompressed assets and having full support, but a slower site/more bandwidth.
  2. Serving compressed assets by compressing them manually, but making the site look like garbage to any browser that doesn't support gzip (there are very few of them now). Note that the extension would still be .html (you don't want to set it to .gz because that implies an archive) but its content would be gzipped.
like image 39
Oleg Vaskevich Avatar answered Feb 24 '23 00:02

Oleg Vaskevich