Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

safari and gzip

I'm loading jQuery from google on my site (http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js) which is minned and gzip'd. In firefox, the jquery file shows as a 19k request, but Safari shows it as a 56k request. I'm assuming then that Safari is not accepting it as a gzip'd file. What's the deal? It's coming from google and I'm pretty sure it's supposed to be gzip'd

like image 623
brad Avatar asked Aug 05 '09 19:08

brad


People also ask

Does Safari support gzip?

Safari does not decompress gzip content when Content-Encoding is gzip,gzip. Bookmark this question. Show activity on this post. Safari for OSX, iOS, and Windows is having issues decompressing Gzip content on my server after a recent server overhaul.

Do any browsers not support gzip?

All modern browsers can handle a gzip encoded response. In fact, if you look at their requests, they'll have a header that says something along the lines of Accept-Encoding: gzip which is their way of saying to the server that they can handle gzipped responses.

Is gzip supported by all browsers?

gzip compression This HTTP header is supported in effectively all browsers.

Does browser decompress gzip?

gzip is commonly supported by web servers and modern browsers, meaning that servers can automatically compress files with gzip before sending them, and browsers can uncompress files upon receiving them.


4 Answers

I found this: you CAN'T use the '.gz' extension when serving compressed CSS or JS files to Safari. It knows how to handle gziped files, as long as they don't have the '.gz' extension (it's just that weird :)

Here's how I serve compressed JS/CSS files to Safari:

  • use any other extension, just not '.gz' ('.jgz', '.foo' or any other one)
  • set the gzip-encoded header for your chosen extensions ('Content-encoding: gzip')
  • set the appropriate MIME type: text/javascript or text/css

all other browsers don't care about what extension you use, as long you set the right content type and encoding, so this works across all browsers.

I successfully tested this with Safari 4.0.4 on Windows XP SP3. And Chrome 4, FF 3.5.5, IE8 and Opera 10.10 on winxp, for the cross-browser compatibility.

like image 166
Trident Splash Avatar answered Oct 01 '22 20:10

Trident Splash


Might want to have a look at this link.

After some digging around I learned that you cannot send compressed javascripts to Safari with the extension of “gz”. It must be “jgz”

So seems the issue actually is with Google serving it up as "gz" rather than "jgz" like Safari wants it.

like image 31
Eric Petroelje Avatar answered Oct 01 '22 20:10

Eric Petroelje


Just thought I'd add to this in case people stumble upon the same question. After playing around with Dev tools more, and looking at response headers, I noticed that the Content-Length actually shows the correct gzip'd size. I can only assume then that it is in fact getting the proper compressed version but in the main resource window it displays the uncompressed size, and the headers show the compressed size.

like image 42
brad Avatar answered Oct 01 '22 18:10

brad


I see at least two possibilities :

  • maybe safari is not sending the HTTP header that indicates "I am able to receive gzip" ; that header is Accept-Encoding, and its value is generally compress, gzip
  • maybe Safari is indicating the size of the un-compressed data ?

Do you have some kind of "network sniffer", like wireshark (seems there is version for MacOS), to really see what's going through the network ?

like image 26
Pascal MARTIN Avatar answered Oct 01 '22 20:10

Pascal MARTIN