bardiir
bardiir

Reputation: 14782

Safari: "Cannot decode raw data" when using GZIP

I've got the issue that when I'm compressing a file (jquery in this case) and then save that gzip content and deliver it to the browser with a Content-Encoding: gzip header it will work in all browsers except Safari, which does state: "Cannot decode raw data"

I need to have the content gzipped already because this is going to be delivered from a µ-Controller which only has enough space to store the gzipped content, and by far not enough processing power as to gzip it then on the fly even if I could store it all.

Upvotes: 3

Views: 2714

Answers (1)

bardiir
bardiir

Reputation: 14782

When you compress data with gzip for safari like this:

gzip jquery.min.js

You will end up with a jquery.min.js.gz which will fail in Safari even when correctly specified as gzip encoded file stream and also when renamed to jquery.jgz as mentioned in a lot of other threads about this issue. This seems to be because the filename is encoded in the gzip file.

If you encode a gzip file like this:

cat jquery.min.js | gzip > jquery.jgz

Then you will have a file that is a few bytes smaller and does work flawlessly with Safari.

Upvotes: 4

Related Questions