Knowledgebase
How to speed up Magento by enabling HTTP compression
HTTP compression is a way of compressing data before it is sent from the web server to the client's browser. This reduces the bandwidth used and as a result speeds up the connection between the server and the client. By enabling HTTP compression, you can speed up your Magento.
By default, HTTP compression for Magento is disabled. The lines in the default Magento .htaccess file which enable it are commented:
# Insert filter on all content
###SetOutputFilter DEFLATE
# Insert filter on selected content types only
#AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
# 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
# Make sure proxies don't deliver the wrong content
#Header append Vary User-Agent env=!dont-vary
This is so because not all web servers have mod_deflate, the Apache module which handles HTTP compression. If the server where your account is hosted has mod_deflate enabled, you need to uncomment the directives above in order to enable HTTP compression for Magento.
All HostKnox servers have mod_deflate enabled by default, so all HostKnox customers can safely enable HTTP compression and speed up their Magento installations.
To enable HTTP compression for Magento, you should edit the default .htaccess file and remove the # symbols in front of the lines above. Don't remove all # symbols, only the ones in front of the Apache directives. The ones for the comments should stay there. This is how the above lines should look like with HTTP compression enabled (Apache directives are in bold):
# Insert filter on all content
SetOutputFilter DEFLATE
# Insert filter on selected content types only
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
# 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
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary