How to Optimize Magento Performance?
Posted on 15 May 2016
Many merchants are not happy with their website speed. Slow websites have low traffic since Google factors speed into search ranking. The lower search ranking, the lower traffic and sales.
Website speed also impacts on your conversion rate. The slower your website, the less is sales conversion and the higher bounce rate.
This article will help you to learn the answer on question “Why Magento is so slow?”. This article also contains practical recommendations so that you could make your Magento website much faster.
Analysis of Magento page loading process
First, let's learn more about page loading process. The image below displays the process of loading a webpage by a browser in a timeline view.
Let us consider a speed report for a new installation of Magento 18.104.22.168.
(To generate a report for your website please go to http://www.webpagetest.org and after generating a report please open “Details” tab.)
So, browser downloaded electronics.html page (9.8KB without resources) within 1.76 seconds, while full web-page (410KB with resources) was downloaded within 4.4 seconds.
Let's see the process of downloading a page without resources in details:
As we can see on the image above, browser spent 149ms on searching requested website (“DNS Lookup” column) and 36ms to establish connection (“Initial Connection” column).
“Time to First Byte” column is very important part of loading a website because it is where the loading of page content and its resources is being started. Time to First Byte (TTFB) represents how quickly the platform of a website (in our case, “Magento”) prepares a requested web-page. The TTFB of a new Magento installation is about 1.5-2 seconds. If you install any popular custom frontend theme full of modules and enhancements, then TTFB can be about 10 seconds.
As we can see, browser spent 1634ms on TTFB and 14ms on content download.
Then we can see that the resources were downloaded asynchronously. The reason is “Max parallel connections per host” limitation. Here is a table with maximum number of parallel connections for most popular browsers. To learn more about the limitations click here.
We can make up some conclusions:
- The loading of a web-page depends on a number of resources on a page. The less resources, the faster page loads.
- The loading of a web-page will be faster if download resources from different domains (hosts).
- The faster browser loads a resource, the faster browser starts downloading the next one.
How to improve the process of establishing connection between browser and server (“Initial Connection” and “DNS Lookup”)?
To improve that stages you need to position of your server (or a group of servers) as close to your potential visitors as possible. To make that you can use “Load Balancing” method. This method will improve time spent on establishing connections and improve downloading content by a browser as well.
How to improve preparing of a requested web-page (Time to First Byte)?
To improve that index you need to use Full Page Caching. Our Full Page Cache extension for Magento significantly improves TTFB (see results in the end of this article). The less is TTFB, the faster browser start downloading of a page content and its resources.
How to decrease number of downloadable resources without abandonment of using them?
- Merge all JS and CSS files into single file (e.g. common.js and commons.css, or install “JS and CSS Compressor” extension for Magento).
- Eliminate all unused and unnecessary resources
- Combine images into sprite
- Use “Expires” header
- Move all small resources into page body. For example, if you use some CSS files of small size (e.g. less than 10KB), then it would be better to place stylesheet content inside of the page.
How to organize content downloading from several domains?
The most effective way is to use Content Delivery Network (CDN).
How to speed up downloading of resources?
- Enable HTTP Compression. Important!
- Optimize images used on your website. To make this see list of recommended utilities, or install “Compressor” extension for Magento that has built-in image optimization processor.
- Compress (minify) JS and CSS files. To make this you can also use “Compressor” extension for Magento.
- Use CDN.
- Place JS scripts in the end of page body. To make this you can refer to this article or just use “Compressor” extension for Magento.
Save money and time
We installed JS/CSS Compressor + Image Optimization and Full Page Cache extensions on that Magento website. These extension use most of the tips described above, and here is the result: TTFB changed from 1634ms to 220ms, while page loading times changed from 4.54sec to 2.78sec.
As you can see, total page loading time improved on 63%, while TTFB is 7.42 times better . The number of downloadable resources decreased from 49 to 26. Considering the dramatic results and affordable price, we believe that those extensions are a great way to optimize Magento website.
Platform: Magento 1900, RWD theme
Server location: Netherlands
Tools for analysis: http://www.webpagetest.org - its server is located at Dulles (Virginia, USA) which is about 6200km from the server in the Netherlands.
Speed up your Magento store with Magento Optimization Tools developed by PotatoCommerce company.