0

I have a site I host on Amazon s3 and distribute through Cloudfront. I am attempting to serve gzipped files. So far I have done the following: 1) gzipped my files.

2) uploading my gzipped files to s3. I now have both the uncompressed and gzipped copies in the bucket. Example: style.css and style.css.gz are in the bucket

3) I made the files public.

4) I checked the metadata on the files and it appears that Amazon already put in Content-Type: application/x-gzip. I assume this is correct.

5) I then add the Content-Encoding by going to the metadata and adding a new piece of metadata: Content-Encoding: gzip

I thought that was all I had to do, but when I go to my webpage now it simply downloads copies of the html files instead of displaying them. Am I missing anything? Im a beginner here so anything helps. Thanks

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
schermee
  • 3
  • 2

1 Answers1

2

Content-Type: application/x-gzip is wrong. The content type must be set to the actual content type of the files, e.g. text/html.

Content-Encoding: gzip is correct and is required.

Michael - sqlbot
  • 169,571
  • 25
  • 353
  • 427
  • Thanks so much! I tried that and the pages are loading but it appears that it's still not serving the browser the gzipped format. Anything else I'm missing? Many thanks – schermee Nov 07 '15 at 22:39
  • It doesn't magically serve the gzipped content, you have to use the .gz links. Alternately, just save *only* the gzipped copy of the file, without .gz... e.g., save the gzipped file as index.html, content-type text/html, content-encoding gzip... that is how I do it. – Michael - sqlbot Nov 08 '15 at 02:53
  • @Michael-sqlbot while googling for answers to my question I keep happening upon your answers. Would you mind taking a look: http://stackoverflow.com/questions/35590622/cloudfront-with-s3-website-as-origin-is-not-serving-gzipped-files? – m0meni Feb 24 '16 at 00:06
  • 1
    lol, @AR7, my reputation precedes me. Actually, I already did have a look. :) I won't have a good opportunity to do any testing until tomorrow, but I saw nothing obviously wrong in your question ... what you are doing to let CloudFront handle the gzipping for you (the question, above, dates from before CloudFront released that feature) *should* work. – Michael - sqlbot Feb 24 '16 at 03:21