Skip to main content
Magento

Speeding up Magento – Using mod_deflate to compress data

By June 23, 2014January 26th, 2015One Comment

Gzip compression used to be a big help in speeding up my Magento sites, however support for the Mod_gzip module ended when my hosting switched from the older Apache 1.3 Web Server to Apache 2.

Introducing mod_deflate module

Mod_deflate is a module for the Apache Web Server, that makes better use of the available bandwidth by compressing content delivered from the web server to the client’s browser. The compression is automatic, with full support provided by most modern browsers.

Speeding up Magento

If Apache is configured with mod_deflate, the content of the file (html/php/js/css etc) will be compressed before being sent to the browser. The browser, then decompresses the file and will display it to the visitor as a simple html file.

Enabling mod_deflate

To enable mod_deflate, you have a .htaccess file in the root of your install with the following code in it:

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css text/csv text/html text/plain text/richtext text/sgml text/tab-separated-values application/javascript application/x-javascript httpd/unix-directory
AddOutputFilter DEFLATE html htm shtml php php4 pl rb py cgi css js txt
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

.htaccess files work recursively, so it will have effect on all the subdirectories as well.

The .htaccess file above will have mod_deflate enabled for all HTML, SSI, PHP, Perl, Ruby, Python, CGI, Cascading Style Sheets, JavaScript and text files.

 

Test that your Magento site is compressed

To test that mod_deflate has been enabled enter your site URL at http://www.whatsmyip.org/http-compression-test/

 

Andrew Taylor

A senior UI designer with over 25 years of web design and web development experience working for some of the largest companies in the UK. An expert in all things Magento and WordPress.

One Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.