How to use deflate in apache config to save bandwidth on webserver

How to save some bandwidth on webserver with deflate..?
my blog now having some sort of heavy usage due to multiple shared hosting package that i’m currently parked..

Found 380 domains hosted on the same web server as (

It appears that the web server located at may be hosting one or more web sites with explicit content. The web sites in question are highlighted in red below. There is a possibility that all of the web sites on this web server may be blocked by web filtering software. Search engine rankings for these web sites may be affected as well.

not having a lot of money to throw in ( move to another package..)
so i have to stick around.. luckily got some optimization option could be done via cPanel itself..
and for mirroring part.. have to do it myself.. assume you had access to /etc/httpd/conf/httpd.conf

After being sometime referring to yahoo Yslow ..
one of the key component is to apply gzip function on css and javascript file..
which haven’t changed that much..

But if want to apply it on all html/text .. but not to images file..
I use the following httpd config..

<VirtualHost *:80>
DocumentRoot "/var/www/html/blog"
DirectoryIndex index.php
# Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
DeflateCompressionLevel 9
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0

and ..

<Directory "/var/www/html/blog">
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
Order allow,deny
Allow from all
AllowOverride All

then have to restart the webserver to apply..

I think can also be applied with the .htaccess file though..

References :


p/s : small saving of bandwidth with something not so difficult to implement.. 😎

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *