I'm making an iPhone application that requests JSON from Heroku.
Am I getting a gzipped response?
And, does the iPhone automatically
unzip gzipped responses, or do you
have to program that in? I'm using
NSURLConnection
asynchronously
(with the delegate protocol) as
described in the Xcode docs.
When I do:
curl -I http://acani.heroku.com/users/4c96ee4f1467281352000049/1234/50/50
I get:
HTTP/1.1 200 OK
Server: nginx/0.7.67
Date: Sun, 17 Oct 2010 16:27:25 GMT
Content-Type: application/json
Connection: keep-alive
Content-Length: 11532
X-Varnish: 2314841869
Age: 0
Via: 1.1 varnish
I'm also using the Zimt WebSocket code with AsyncSocket for chat. The chat server is Node.js. Should I be gzipping each chat message? Or is that done automatically?
I wonder, to reduce bandwidth, does Twitter gzip your tweets (with JavaScript on the web, or Objective-C on the iPhone) before they are sent to Twitter?
Thanks!
Matt
You can tell using Developer Tools (F12). Go to the Network tab, select the file you want to examine and then look at the Headers tab on the right. If you are gzipped, then you will see that in the Content-Encoding.
Gzip (GNU zip) is a free and open source algorithm for file compression. The software is overseen by the GNU project. In this context, compression is the deliberate reduction in size of data to save storage space or increase the data transfer rate.
Turns out yes - you can and should gzip the custom font files you use with @font-face .
To detect if a response is compressed or not, you need to look for a Content-Encoding
header. It can be set to either gzip
, compress
, or deflate
. See RFC 2616 Section 3.5 for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With