Speed up Apache 2.0 web access or downloads with mod_deflate
Posted by nixcraft
You can speed up downloads or web page access time with Apache mod_deflate module. The mod_deflate module provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network.
This decreases the amount of time and data transmitted over the network, resulting in faster web experience or downloads for visitors.
Make sure mod_deflate included with your Apache server (by default it is now installed with all modern distro).
Configuration
Open httpd.conf file:
# vi httpd.conf
Append following line:
LoadModule deflate_module modules/mod_deflate.so
Append following configuration <Location /> directive:
<Location />
AddOutputFilterByType DEFLATE text/html text/plain text/xml
….
…
<Location>
Above line only compress html and xml files. Here is the configuration from one of my production box:
<Location />
…
…
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
…
…
<Location>
Save the file and restart apache web server. All of the above extension file should compressed by mod_deflate.
# /etc/init.d/httpd restart
You can also specify specific directory and enabling compression only for the html files. For example /static/help/ directory:
<Directory “/static/help”>
AddOutputFilterByType DEFLATE text/html
</Directory>
In real life, there are issues with compressing other types of files such as mp3 or images. If you don’t want to compress images or mp3 files then add following to your configuration:
SetOutputFilter DEFLATE
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
SetEnvIfNoCase Request_URI \.avi$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mov$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mp4$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.rm$ no-gzip dont-vary
See also:
* mod_deflate home page
原文出處:
http://www.cyberciti.biz/tips/speed-up-apache-20-web-access-or-downloads-with-mod_deflate.html
,挖過的痕跡這麼明顯 =>
=>


(前途茫茫的我…)、無言、錯亂、瀕臨崩潰的支撐下…
