Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I've heard it suggested that using setting a page's Content-Encoding to zip or gzip will drive down load times and reduce bandwidth. Is this worth implementing for the average site or only sites with a high load? Also, how does one go about setting up pages to be served in this way in a LAMP environment? Is there a practical difference between zip and gzip?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

This is absolutely worth doing, even for sites with average to low traffic levels. Although it will reduce your bandwidth (with a slight increase in CPU usage), the real benefit is to your users. Even on broadband you can notice a performance improvement when accessing compressed pages, but your users on slower network speeds and newer smartphones will really appreciate it.

share|improve this answer
add comment

The browser may send an "Accept Encoding" header which says it can accept different kinds of encoding. Usually this is "gzip, deflate". (Google Chrome has a weirdo format called "sdch" which you can just ignore.) Then, if you get that header from the browser, you can, if you wish, send your content back compressed using either the gzip or the deflate format. When you do that, of course you need to tell the browser what you've done, so you add the "Content Encoding" header to your outgoing stuff.

Both the gzip and deflate formats are defined in RFC (internet standards documents). There is no "zip" option, although there may be a "bzip2" option in some browsers.

Now your problem is to encode your stuff in that format and send it back. If you are using Apache there are ways to set it up to do that automatically (mod_deflate etc.). If you are sending images then note that most image formats like JPEG, PNG, GIF, etc. are already compressed so you don't get any benefit from compressing them. Basically it only works for HTML, CSS, plain text, or JavaScript.

You need to be careful using the "deflate" encoding since Internet Explorer has a long-standing bug where it doesn't understand that too well. I believe that fancy-pants things like Google App Engine will automatically work out what compression to use and apply it for you.

share|improve this answer
add comment

To extend on Jason Birchs and Kinopikos answers: another increasingly important reason why you absolutely want to apply this (very simple) optimization is Googles announcement to use site speed in web search ranking as of April 09 2010. You surely don't wanna miss out on an improvement regarding your SEO efforts that easy ;)

Once you start looking at things from that angle you'll most likely benefit from (and enjoy working with) the respective tools giving you insights into how your pages perform and what you can do about it to improve them:

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.