Compressing Web Content with mod_gzip and mod_deflate

Compressing Web content can produce a much faster site for users. Here's how to set it up and measure your success.
Conclusion

With a few simple commands and a little bit of configuration, an Apache Web server can deliver a large amount of content in a compressed format. These benefits are not simply limited to static pages; dynamic pages generated by PHP and to other dynamic content generators can be compressed by using the Apache compression modules. When added other performance-tuning mechanisms and appropriate server-side caching rules, these modules can reduce substantially necessary bandwidth for a very low cost.

Stephen Pierzchala is senior diagnostic analyst for Keynote Systems in San Mateo, California. His focus is on analyzing Web performance data and evangelizing on Web performance topics, such as content compression, caching and persistent connections. He can be contacted at stephen@pierzchala.com.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I had no idea you could do

David Hops's picture

I had no idea you could do this. Should come in handy as I don't have much bandwidth at the moment and am hosting a few large images and zips. Only concern would be extra CPU load.

Great article, thank you for

Webtiful Search Engine SEO's picture

Great article, thank you for sharing.

mod_deflate

Mikhailov Anatoly's picture

Article about mod_deflate settings like on Amazon EC2 AMI
http://railsgeek.com/2008/12/16/apache2-httpd-improving-performance-mod_...

Nice Work!

Fargham's picture

A great and informative article!

Really helped me!!

Ashutosh Chaturvedi's picture

Hi,

It's really a great artical and really helped me. One question from myside is..

Is there anyway of copressing .tiff files by using mod_gzip??

Plz help me, if anyone has idea about the same.

Thanks in advance..

Ashutosh

Brain Cancers

seda's picture

I read your article.The things you have written sound very sincere and nice topics i am looking forward to its continuation.

Re: Compressing Web Content

Anonymous's picture

stephen,
good article summarizing the methods and benefits of compressing web pages. however, you should touch on the difficulty of using mod_gzip with mod_ssl under apache 1.3.x -- this is a cumbersome issue and there are only workaround solutions. one such is to use a mod_proxy frontend virtual server to buffer the ssl request, and a mod_gzip backend virtual server to handle the compression. more detail on this two stage approach is here:
http://lists.over.net/pipermail/mod_gzip/2002-February/005911.html
i have implemented the above method on a few production servers and it does indeed work, with some caveats.

i believe that i read somewhere that apache 2.x had improved handling of the gzip/ssl pairing. not having played with 2.x i'm not in a position to say whether or not it actually works. perhaps someone could comment on this.

regards,
jim

At what cost to the CPU

Anonymous's picture

Great article! I enjoyed reading it and found it very informative. One question though...

What will this module do to my CPU? Will the load average on my box go through the roof everytime I need to send out a compressed webpage? I think this would have been a nice point to look at as part of your article.

Really helped me!!

Ashutosh Chaturvedi's picture

Hi,

It's really a great artical and really helped me. One question from myside is..

Is there anyway of copressing .tiff files by using mod_gzip??

Plz help me, if anyone has idea about the same.

Thanks in advance..

Ashutosh

compressing .tiff files

Marcus's picture

To compress TIFF files, simply remove the following exlusion for images from the above example configuration:

mod_gzip_item_exclude mime ^image/.*$

Also, add the .tif file extension in the file inclusions:

mod_gzip_item_include file \.(tif)$

Please let me know if you add this because I'd like to test a browser implementation against it. Thanks.

Marcus Adams
yEnc Decoder Proxy

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix