fredjean / middleman-s3_sync

The gem that tries really hard not to push files to S3.
MIT License
271 stars 75 forks source link

Gzipped resources on S3 #126

Closed 5t111111 closed 8 years ago

5t111111 commented 8 years ago

As described in README, when you set prefer_gzip, gzipped version of the resources should be pushed to S3.

And the logs also says like the following:

s3_sync  Creating 2016/01/03/an-article/index.html (gzipped)

However, I can find only uncompressed resources like index.html instead of index.html.gz on S3 Management Console, Content-Encoding seems to be correctly set as gzip though.

I'm not sure if this is expected behavior.


middleman-s3_sync (4.0.2)

fredjean commented 8 years ago

It is. S3 is a purely static store and does not perform content negotiations with the clients. We are cheating by pre-compressing the file and reporting it's content encoding as gzip. Browsers that support gzip encoding (which should be all browsers at this point) sees it as being compress and handle it properly.

Cloudfront can perform content negotiation and it will compress files on the fly if the browser requests it.

5t111111 commented 8 years ago

Thank you, but I still have a question.

From what I understand, if middleman-s3_sync handles generated files by the following steps,

We are cheating by pre-compressing the file and reporting it's content encoding as gzip

there should exist files like index.html.gz on S3, don't they?

However, as i wrote before, S3 Management Console looks like the below:

s3_management_console

fredjean commented 8 years ago

We push the content of index.html.gz into index.html on S3 so that the links still work. We do not push the original, non compressed content up.

On Sat, May 21, 2016, 6:39 PM Hirofumi Wakasugi notifications@github.com wrote:

Thank you, but I still have a question.

From what I understand, if middleman-s3_sync handles generated files by the following steps,

We are cheating by pre-compressing the file and reporting it's content encoding as gzip

there should exist files like index.html.gz on S3, doesn't it?

However, as i wrote before, S3 Management Console looks like the below:

[image: s3_management_console] https://cloud.githubusercontent.com/assets/333180/15451506/92535e72-2000-11e6-9110-a2e08749f1d5.png

— You are receiving this because you commented.

Reply to this email directly or view it on GitHub https://github.com/fredjean/middleman-s3_sync/issues/126#issuecomment-220807934

Fred Jean (fred@fredjean.net)

5t111111 commented 8 years ago

Now I understand how it works. I really appreciate your help, thanks!