// you’re reading...

Apache / PHP / MySQL

Utilizing mod_deflate & zlib for web performance

Every webmaster is looking for ways to enhance performance. I’ve researched the web and found some hits and some misses. Here are a couple changes that have dramatically improved Apache and PHP performance for me. Of course, this is my implementation, and I’d like to hear from others how I could improve.


Using mod_deflate:

For my purposes, I wanted to implement compression globally. So in my httpd.conf file, I made the following entries:

# # # # # # # # # # # #
# mod_deflate
AddOutputFilterByType DEFLATE text/js
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/csv
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/x-httpd-eruby
AddOutputFilterByType DEFLATE text/html
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$
no-gzip dont-vary
SetEnvIfNoCase Request_URI
.(?:exe|t?gz|zip|bz2|sit|rar)$
no-gzip dont-vary
SetEnvIfNoCase Request_URI .pdf$ no-gzip dont-vary
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
DeflateFilterNote Input input_info
DeflateFilterNote Output output_info
DeflateFilterNote Ratio ratio_info
LogFormat ‘”%r” %{output_info}n/%{input_info}n (%{ratio_info}n%%)’ deflate
CustomLog /var/log/httpd/deflate_log deflate
# # # # END mod_deflate # # # # #

Using zlib compression:
Again, in my case I wanted to make compression global, so in my php.ini I un-commented and modified it to the following:
zlib.output_compression = On
zlib.output_compression_level = -1
*Note: the -1 setting allows the server to choose the compression level.

Thoughts?

Discussion

No comments for “Utilizing mod_deflate & zlib for web performance”

Post a comment

 

June 2009
S M T W T F S
« Apr   Jul »
 123456
78910111213
14151617181920
21222324252627
282930