brad
brad

Reputation: 32355

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

Upvotes: 9

Views: 10026

Answers (5)

Apollo Clark
Apollo Clark

Reputation: 806

I've run into this problem as well, while trying to optimize the load time of a website on iOS7 Safari mobile iPad.

  • Encoded = uncompressed filesize, from server
  • Decoded = uncompressed filesize, locally
  • Transferred = uncompressed file size + headers sent and received
  • Content-Length = compressed file sent, from server

Safari chose a really weird way of representing these numbers in their debugger.

Upvotes: 0

brad
brad

Reputation: 32355

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.

Upvotes: 4

Trident Splash
Trident Splash

Reputation: 649

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.

Upvotes: 14

Pascal MARTIN
Pascal MARTIN

Reputation: 401182

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 ?

Upvotes: 1

Eric Petroelje
Eric Petroelje

Reputation: 60549

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.

Upvotes: 7

Related Questions