views:

948

answers:

4
+4  Q: 

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

+3  A: 

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.

Eric Petroelje
This might be true, but is irrelevant here since it's evidently serving it up as `.js` considering the URL brad provided.
mercator
+1  A: 

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 ?

Pascal MARTIN
Gave wireshark a brief chance but it had a bunch of errors on load and didn't load up any network interfaces. I think Eric has a good point although that's incredibly frustrating if I can't use google to serve gzip'd files
brad
Too bad :-( The link @Eric posted speaks about some kind of .gz or .jgz extension ; I see none of those in the URL you gave : it has a .js extension -- and google not sending gzipped data seems a pretty strange idea, considering that safari is a recent browser, and that it would help them reduce bandwith costs... Still... If you find the solution, let us know !
Pascal MARTIN
+2  A: 

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.

sopppas
A: 

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.

brad