.htaccess configuration
Normally be able to enable mod_deflate module for Apache2 safely with the following lines inside your .htaccess file in your www root of your website:
<ifmodule mod_deflate.c> # Insert filter SetOutputFilter DEFLATE # Compress Level 9 - maximum DeflateCompressionLevel 9 # Netscape 4.x has some problems... BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4\.0[678] no-gzip # MSIE masquerades as Netscape, but it is fine BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # Don't compress images SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary # Don't compress archives and pdf SetEnvIfNoCase Request_URI \ \.(?:exe|t?gz|zip|bz2|sit|rar|pdf)$ \ no-gzip dont-vary # Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary </ifmodule>
Virtual Host Notes
Some people argue that configuration in the VHost is better because it saves your server the disk IO of accessing the .htaccess file with every request (Note: for VHost configuration you will need to be admin of your server).
Save above rules in a file, named mod_deflate.conf and copy the file to /etc/httpd/conf.d//etc/httpd/conf.d (CentOS)
Testing
To test if mod_deflate is work, go to http://www.whatsmyip.org/http_compression/ and we enter the whole URL to your website or stylesheet or javascript file. You should see a big green tick and the site will say the PAGE or CSS or JAVASCRIPT is compressed.
Website Performance
Also, here a Free Website Performance Tool and Web Page Speed Analysis Enter a URL below to calculate page size, composition, and download time.
