2008
11.25

The HTTP Server Data Compression

The HTTP Server usually transfers data without compression by default. I searched in the Internet and found an article to teach me how to load and configure the compression module. (mod_deflate)

I use Debian Linux 4.0 with Apache 2.2.3 .

First, use switch user do to switch user to root (must in sudoer)

root@taipei:/etc# sudo su

Second, enable the Aapche2 module “deflate” to compress your transfer data.

root@taipei:/etc# a2enmod deflate

Third, config your /etc/apache2/mods-enable/deflate.conf . The DeflateCompressionLevel is from 0 to 9, accroding to the opinions from other’s blog, they said “level 6″ is the best parameter with good compression rate and medium CPU usages.

<ifModule mod_deflate.c>
       DeflateCompressionLevel 6
       AddOutputFilterByType   DEFLATE text/html text/plain text/xml application/x-httpd-php
       AddOutputFilter         DEFLATE  html  htm  xml  php  css  js
</ifModule>

Then, restart your web server, everything is done.


The testing result is calculated by Port80 Compression Check . Now, we know the deference between the data size with zip compresstion or not.

P.S. You also can configure the /etc/php5/apache2/php.ini to enable the “ob_gzhandle”, or “zlib” (must load the zlib extention), but both of them can’t compress the static html pages, js, or css files.

refer: http://twntwn.info/blog/ajer001/archives/1889, thanks for ajer’s article.

No Comment.

Add Your Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>