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 (co开发者_如何学运维rrect 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?
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
.
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.
精彩评论