How to enable GZIP Compression in Apache Server to Speed up Website

September 15th, 20123 Comments

Compression is a simple and effective way to speed up your site. Modern browsers supports gzip compressed content and are capable of uncompressing gzip data into plain text.

The gzip module configuration depends on your Apache Server version:
Apache 1.3 uses mod_gzip while Apache 2.x uses mod_deflate.

mod_gzip configuration for Apache 1.3.x:

<IfModule mod_gzip.c>
 mod_gzip_on Yes
 mod_gzip_dechunk Yes
 mod_gzip_item_include file \.(html?|txt|css|js|php)$
 mod_gzip_item_include handler ^cgi-script$
 mod_gzip_item_include mime ^text/.*
 mod_gzip_item_include mime ^application/x-javascript.*
 mod_gzip_item_exclude mime ^image/.*
 mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
 </IfModule>


mod_deflate configuration for Apache 2.x:

<IfModule mod_deflate.c>
 SetOutputFilter DEFLATE 
 # Don't gzip
 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 
#Dealing with proxy servers
 <IfModule mod_headers.c>
 Header append Vary User-Agent
 </IfModule>
</IfModule>

Online web page compression / deflate / gzip test tool
1. Port80 Compression Check
2. GIDZipTest

Resources
Apache Module mod_deflate
Compressing Web Content with mod_gzip and mod_deflate
Speed up Apache 2.0 web access or downloads with mod_deflate

Related Posts:

Tagged : , , , ,