Magento 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.
...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 and Magemojo. Use google search and find a company you like.