Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 232
bardiir Avatar asked Aug 02 '26 13:08

bardiir


1 Answers

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.

like image 57
bardiir Avatar answered Aug 07 '26 02:08

bardiir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!