Liron Harel
Liron Harel

Reputation: 11247

Serving gzip content from on Amazon S3 - doesn't work with my application

I've gziped my JavaScript file using gzip and uploaded it to Amazon S3. I've set the following:

content-type: application/x-javascript
content-encoding: gzip

The file was given public permissions.

The problem that when I refer the script to the location (correct one, I've checked) of the gzipped file (with js.gzip at the end), the application doesn't run it. When I tried to view the file in Chrome browser, it tried to download the file instead of showing it.

What I'm doing wrong?

Upvotes: 0

Views: 1770

Answers (2)

juancho
juancho

Reputation: 21

Try to remove:

content-type: application/x-javascript

and only use:

content-encoding: gzip

in your S3 bucket file.js file (gziped, replace .js.gz for .js only).
Now the browser request should work without any problem.

Upvotes: 2

Alex
Alex

Reputation: 9481

According to one answer of a similar question, there's a bug in Safari (probably Webkit) which stops proper gzip acceptance with the "wrong" file extension.

File extension shouldn't matter, but apparently Webkit screws it up. try either .jgz or .gz.js.

Upvotes: 2

Related Questions