Just another WordPress weblog
Handlers Apache 2.0 and 2.2 allow you to compress content before sending it to the visitor’s browser. Types of content to be compressed, set the type of MIME. This function requires the correct operation of the command handler mod_deflate Apache. Before modifying configuration file, don’t forget to back up your .htaccess.
Add the following lines to your .htaccess file:
<IfModule mod_deflate.c>
AddOutPutFilterByType DEFLATE text/html text/plain text/xml
<IfModule mod_setenvif.c>
# 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# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won’t work. You can use the following
# workaround to get the desired effect:
BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html# Don’t compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
</IfModule><IfModule mod_headers.c>
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>
This will make your website work really faster and your visitors will feel grateful to you, which means they will be more loyal and more of them will turn into your permanent customers.
p.s. If for some reason your server returns Error 500 (Internal Server Error), try asking your host support how to enable GZIP compression on your website.
This blog is about website monitoring industry events and news. And of course everything that is somehow related to web, IT and/or networking.
1 Response to Improving Website Performance With .htaccess File Configuration
Website Performance
February 26th, 2010 at 10:57 am
This is great advice, and one of the most often overlooked areas of performance optimization. Compression, especially for text content such as HTML or CSS, can easily reduce transferred bytes by 80% or more.
Caching is very important to setup properly as well. Yahoo research shows that 80% of web traffic is cache-primed, so with the proper content expiration you can seriously reduce the number of web server requests!