Using gzip Compression in Apache to Serve Pages Faster
Enabling gzip compression in Apache will dramatically reduce the amount of data transmitted. This is easily accomplished by doing the following as root:
cd /etc/apache2
cat <<\! > httpd.conf.local
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ \
no-gzip dont-vary
SetEnvIfNoCase Request_URI \
\.(?:exe|t?gz|zip|bz2|sit|rar|7z)$ \
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
!
vi /etc/sysconfig/apache2
Make the following changes:
APACHE_CONF_INCLUDE_FILES="/etc/apache2/httpd.conf.local"
APACHE_MODULES="... deflate"
Restart apache
/etc/init.d/apache2 restart
Test your website for speed improvement.
cd /etc/apache2
cat <<\! > httpd.conf.local
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ \
no-gzip dont-vary
SetEnvIfNoCase Request_URI \
\.(?:exe|t?gz|zip|bz2|sit|rar|7z)$ \
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
!
vi /etc/sysconfig/apache2
Make the following changes:
APACHE_CONF_INCLUDE_FILES="/etc/apache2/httpd.conf.local"
APACHE_MODULES="... deflate"
Restart apache
/etc/init.d/apache2 restart
Test your website for speed improvement.
Total Comments 1
Comments
-
Apache to Serve Pages Faster...
how gzip can make it faster for apache I wonder?
by the way for a faster serving you might want to try out nginx.Posted 11-07-2010 at 07:24 AM by Web31337
Updated 11-07-2010 at 07:25 AM by Web31337