views:

39

answers:

4

I'm targetting a couple of web projects at mobile users, and noticed that some of the standard tools (JS libraries, json transfers, xml etc) are quite heavy for mobile data plans.

I'd like to be able to implement gzip'd resources, and probably mod_deflate/mod_gzip to try and reduce the amount of bandwidth used by these devices.

However, I don't know how widespread support for gzipped javascript, gzipped html etc. is on mobile devices, or even if it is common practice to use...? It seems to make sense though.

Is it ok to use as a solid tool for the common mobile devices..? iPhone, android, blackberry, windows mobile/opera..?

Thanks.

+5  A: 

I don't think it matters, a browser will request GZipped data if it supports it, so your server will only GZip it if your browsers asks it to.

ILMV
How about script tags with .gz compressed source?
danp
If you're using .gz compressed source you need to provide the original too. This is the reason compressing the file on an individual basis is not as popular as on the fly GZipping with .htaccess for example, as it handles all of this for you.
ILMV
Sure, if apache is gzipping everything, there's no point :) However, supplying a .js.gz file to the client will work even when you cannot enable mod_gzip/deflate (on shared hosting, for example)...? Maybe this is better handled by another question.
danp
You make a good point, but I think (as long as the module is available) this can be handled by a .htaccess file. I don't know exactly how .gz files work, but I guess when they're requested the server zips them up? If this is the case the server has the GZip module available and it can be achieved on an automatic basis.
ILMV
Exactly, needs a question just for this, I think. All a bit vague. I'll go ahead and accept your answer though, thanks to all.
danp
+1  A: 

mod_deflate / mod_gzip will check the client's "accept" headers and turn compression on or off accordingly.

Just turn it on in your server, and make sure your js and css resources get compressed as well. You can use Firebug's "Net" tab to check whether compression was applied to the loaded resources.

If compression is mising for certain file types, check out this question for how to turn it on.

Pekka
+1  A: 

As far as I know much of them supports it, but if you configure you're server well it will be able to send non-compressed resources if needed.

Another benefit is that you imporove caching as some devices like iPhone has limits of 25k for a content to be cached.

So the short answer is: Just Do It

galambalazs
+1  A: 

Go for it - the gzipped version should be only sent if a browser sends an Accept-Encoding: gzip (and the modules check for this automatically). (see the relevant part of RFC 2616)

(the usual warning applies - some browsers are broken. For example, IE6 advertises gzip-capability but doesn't actually support it properly. For mobile browsers, I haven't encountered such brokenness yet - so far every mobile browser that advertised gzip supported it)

Piskvor