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?

  • I think: zip = deflate – Oskar Skog Jul 21 '17 at 15:58

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.


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.


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:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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