Get More Out of Your Pipe with Apache and mod_gzip - page 2
It's Not Magic
Configuration is the tedious part, because Apache refuses to read your mind, and insists that you define every last thing in httpd.conf. First, tell Apache to load your nice new mod_gzip module; put this line with the other LoadModule entries:
LoadModule gzip_module modules/mod_gzip.so
Next, find the AddModule lines, and add:
Now you can stuff all the mod_gzip directives into its own IfModule section:
#turn mod_gzip on. You can disable it in individual virtual hosts, #if you wish mod_gzip_on Yes #this tells mod_gzip to re-use compressed files, instead #of compressing them for every request mod_gzip_can_negotiate Yes #assemble all the bits of a dynamically-generated page, #and compress it as one page mod_gzip_dechunk Yes #there's no point in compressing small files (bytes) mod_gzip_minimum_file_size 600 #sometimes scripts create loops- you #don't want mod_gzip to get stuck, and create #an enormous file that eats your hard drive #and crashes the server mod_gzip_maximum_file_size 100000 #maximum size of file in memory mod_gzip_maximum_inmem_size 100000 #temp files- say yes only for debugging mod_gzip_keep_workfiles No mod_gzip_temp_dir /usr/local/apache/gzip # define the required HTTP version of the client, to #automatically weed out requests from antique browsers, #proxy servers, search engines, bots, and other entities #that cannot handle compression. Only uncompressed #pages will be served to these. #1000 = HTTP/1.0, 1001 = HTTP/1.1 mod_gzip_min_http 1001 #exclude these from compression, because they are #troublemakers mod_gzip_handle_methods GET POST #now the fun stuff- tell which file and mime types #you want compressed mod_gzip_item_include file \.html$ mod_gzip_item_include file \.html$ mod_gzip_item_include file \.shtml$ mod_gzip_item_include file \.shtm$ mod_gzip_item_include file \.txt$ mod_gzip_item_include file \.jsp$ mod_gzip_item_include file \.php$ mod_gzip_item_include file \.pl$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-httpd-php mod_gzip_item_include mime ^httpd/unix-directory$ mod_gzip_item_include handler ^perl-script$ mod_gzip_item_include handler ^server-status$ mod_gzip_item_include handler ^server-info$ mod_gzip_item_exclude file \.css$ mod_gzip_item_exclude file \.js$ mod_gzip_item_exclude mime ^image/.*
Naturally, you will want to refine this for your own needs. Find the mod_gzip.conf.sample file on your system; it's a detailed reference for mod_gzip options. When you're finished, restart Apache. And that's pretty much all there is to it--a few minute's work for an immediate large payback. If only more things in life worked like this.
The author of mod_gzip, Michael Schrï¿½pl, has configured his Web site to recognize the language setting in your browser, and to deliver either German or English pages accordingly. In Mozilla/Firefox/Netscape, edit -> preferences ->navigator -> languages. In Opera, file -> preferences -> languages. In other browsers, eh, you'll figure it out.
Sponsored by BlackBerry
BlackBerry® Enterprise Server Express enables businesses of any size to quickly and easily get started with the BlackBerry solution. It provides advanced BlackBerry smartphone features with no additional software or user license fees, and works with any Internet-enabled BlackBerry data plan or a BlackBerry enterprise data plan. Download now!