Skip to main content

What’s more annoying than landing on a website only to find it’s slow and taking far too long to load each page?  Answer: Nothing.  What is equally annoying is spending huge amounts of time and money working on your on-site SEO and gaining high quality links, only to realise that your slow website is affecting your page rankings.

 

Magento is arguably the best open source e-commerce CMS platform on the market, which is why we use and recommend it to businesses looking to sell their product online.  However, out of the box, it is notoriously slow and uses a lot of your server resources.  Don’t expect Google Pagespeed scores much above the 30 mark without completing some work optimising Magento for speed.  There are some quick and easy fixes, cheap and expensive fixes and combinations of both, however what we are about to show you is both quick and inexpensive…aka as FREE! (assuming you are verse in a little coding).

 

Now before I go into all this in detail, a very big thanks (and reference) must go to the Sergey Dvoskin at Turnkeye eCommerce for his hard work and generous sharing of this info.

 

First things first, we run a compression test at http://www.whatsmyip.org/http-compression-test/ and see if a) Compression is already being used and b) if not, how big might the savings be if we did.  Expect to see pretty big % savings should your site not already be set up for compression.   Now your asking, so how do we turn on compression?

Great question, and a relatively easy answer.  It involves making some small changes to your .htaccess file in the root folder of your Magento install, which will enable gzip compression of your magento files.  Please note, this is a very important file and as such, if your not familiar with Magento and coding in general, we don’t recommend you attempt this fix.  Just contact us or another developer to sort it our for you!   If you do attempt this, as always, ensure you have a full backup of your site just in case you make an accidental mistake!  Now, disclaimers aside…time to get started.

You need to find the below section of code:

 

############################################

## enable apache served files compression

## http://developer.yahoo.com/performance/rules.html#gzip

# 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

 

and replace it with:

 

############################################

## enable apache served files compression

## http://developer.yahoo.com/performance/rules.html#gzip

# 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

 

After this, you need to check that the ExpiresDefault “access plus 1 year” is not commented in the same .htaccess file.

############################################

## Add default Expires header

## http://developer.yahoo.com/performance/rules.html#expires

ExpiresDefault “access plus 1 year”

 

Additionally you also need to check that ‘php_flag zlib.output_compression on’ is also set on or enabled.


############################################

## enable resulting html compression

php_flag zlib.output_compression on

 

After making the above changes and saving the new .htaccess file…go back to the Compression Test page and re-run the test.  Check that compression is now enabled and view the % savings you’ve just made!

 

Making Magento faster can be both quick and inexpensive with the above changes to your .htaccess file.   We noticed significant increases in Google Page Speed insights after completing the above changes…and by significant we mean 20-30 point score increases!  Not bad for a quick and inexpensive fix to make Magento faster!

Leave a Reply