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
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.
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 generallycompress, 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 ?
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.
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.