3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
E-commerce site speed is important. Not only fast sites convert better
but they also tend to rank higher
in google search engine.
is a popular eCommerce content management system which is free and open source. There are two major versions of it: 1.x and the latest 2.x release. It is ideal for small to mid-size online businesses wanting to offer e-commerce experience to their customers.
Magento 1.x is known for its sluggish performance. Just google for 'Magento slow
' and you will find a dozen store owners complaining their site isn't fast enough.
Disclaimer: The following points apply to Magento 1.x only. Magento 2 was designed to be fast (unlike Magento 1.x) and if it is not for you please leave a comment at the bottom of this article - I will help.
Time to first byte
1. Optimize time to first byte (TTFB)
as defined by webpagetest.org
...is the time from the start of the initial navigation until the first byte of the base page is received by the browser (after following redirects).
1.1 Enable Magento Profiler
Magento offers a way to measure and audit TTFB for every page by using its built-in profiler feature. Here is how to enable it:
1. Edit index.php and uncomment Varien_Profiler::enable line like this:
2. Go to backend main menu System > Configuration > Advanced > Developer > Debug > Profiler and set it to Yes:
Once you did #1 and #2 you should see profiler output at the bottom of every page you visit:
Alternatively you can install Aoe_Profiler
extension and have it all wrapped up in a nice backend Magento grid.
1.2 Audit Profiler Output
Go through profiler output line by line and see what is taking more than 0.1s. 0.1s threshold is subjective - analyze everything you think has to be analyzed.
Common issues found with profiler help:
1. A third-party extension event observer takes too long
- you installed an extension from Magento connect and some of its code is run on every page request slowing you down. Do you really need this plugin? Try contacting vendor or replace it with another one.
2. Template .phtml file is slow
- that is a sign of a poor coding. Go through the file and audit PHP code. Common problem - loading a Magento model inside a loop (say Mage::getModel('catalog/product')->load($product_id)
) - I see it too often:)
3. A function called too many times
- profiler output has Cnt
column that shows how many times a function call has been executed. Pay attention to that column. If Cnt
is over 100 - that is a red flag. Check out the corresponding code lines and see if there is a room for improvement.
2. Optimize server environment
Next thing (actually that should be #1 on your list) to focus on is server environment.
2.1 Magento Optimized Hosting
Go for Magento optimized hosting not just an average $10/mo shared account. That will pay off. A few examples are Nexcess
. Use google search and find a company you like.
PHP7 is out and its performance benefits
in comparison to PHP5 are proven.
Magento 1.x supports PHP7 with the help of Inchoo patch
is in-memory data store engine.
Magento can use Redis as cache / session backend. Here is an official instruction on how to set it up
Redis helps speed up product saving, checkout process and many other Magento operations - proof by Nexcess
3. Full Page Cache extension
Magento 1.x Community Edition doesn't have full page cache extension. Enterprise edition does. For a reason - it really helps speed up the site and improve user experience.
Full page cache (FPC) stores full pages in cache and serve them as fast as static content.
Although I often say CACHE != PERFORMANCE I still recommend getting and installing FPC on your Magento store.
Browser for available FPC extensions on Magento connect
and pick the one you like.