MAGENTO PERFORMANCE TESTING TOOLS:
Before we start looking at the Magento speed optimisation steps, it is better to first discuss the choices you have to determine the actual page load time of your Magento store. Though, a quick Google search query will give you a long list of websites which will provide basic information around your website’s speed, I would recommend looking to use yslow or Google Page Speed Tool, as they are the most widely used tools and will give you accurate results.
If you already have a Magento store, I’d suggest that you check its page load time before you start the following the following performance optimisation techniques, and see how much your website’s performance improves. Don’t forget to provide your feedback in the comments section below.
Another thing to think about is that each of your page templates will have different page load speeds, because of the reliance on different files and front-end assets. It’s important to monitor and test each page type and then use the methods below to optimise each one.
OPTIMISING MAGENTO’S PERFORMANCE
If you are in the process of launching a new store and are looking at hosting options for your Magento store, the first step towards optimising Magento performance should be to find a good server, which is suitable for Magento. Really, any Magento store should be using an optimised dedicated server, but if there are cost constraints, as there usually are for smaller merchants, then you should find some reliable shared hosting company which specialises in Magento hosting.
In the past I’ve used Rackspace, Nexcess and Peer1 (all specialists in Magento hosting), as well as SWBroadband for smaller Magento websites. Sonassi also have a really strong reputation in the Magento community.
ADMIN PANEL CHANGES
The fastest and easiest way to significantly increase your Magento store’s performance is by making some basic changes to the admin panel. The following are relatively easy things to change but can have a big impact on the load time of your website.
First of all go to System > Configuration > Catalog > FrontEnd and select “Yes” for both ‘Use Flat Catalog Category’ and ‘Use Flat Catalog Product’.
Secondly, we have to disable logging in the log settings. For that go to System -> Configuration -> Advanced -> Developer -> Log Settings and make sure log settings is not enabled.
Another important step is to enable cleaning of cron and log at regular intervals. For that go to System > Configuration > Advanced > System -> Log Cleaning, here you should enable log cleaning and set the minimum possible time which is viable for you.
Now, we’ll enable merging of CSS and JS files at the time of page loading. Although this a fundamental step in the process of improving the speed of your store, it can also cause problems, so I’d suggest you don’t look at this without the assistance of an experienced Magento developer.
Once this is done, we’ll run the Magento compilation process. In this step Magento will compile all of its files to create a single include path, which will help us reduce page load time by up to 50%. To run this compilation process, go to System > Tools > Compilation. In the top-right hand corner, you’ll see the Run Compilation Process button. Click on that and you’re done.
If you experience any problem in running this compilation, please make sure that the directory ‘includes’ and the file ‘includes/config.php’ are both writable.
The last change we want to make in the admin panel is enabling the Magento cache. This way Magento stores will load the resources at the first page request, which will allow the use of the already downloaded resources for subsequent page requests being loaded. This will help us to reduce page load time significantly. To enable Magento cache, go to System > Cache Management. Select all cache types and from the top-right corner drop down select Enable and submit.
Now, we’ll start making some changes in Magento’s .htaccess file. For this purpose you have to locate the .htaccess file located in the Magento root directory. If you can’t find this, try creating a new one.
This part is only really relevant to Magento websites that are using Apache servers and not Nginx – so this may not be relevant to all readers. Also, people running Magento Enterprise websites are probably not going to be using the .htaccess with Apache because it’s slower.
Through this .htaccess file, we’ll do couple of things. First of all, we’ll add expiration durations in headers. That means, until the duration mentioned in headers is not expired, Magento will keep using cached version of the files, and will not download new ones. Secondly, we’ll do content encoding to compress the files before sending them to requesting agents. As files will be smaller, they’ll be download faster.
First of all, we need to place an expiration limit on the headers, by adding this code into the .htaccess file:
First of all enable expirations
ExpiresDefault “access plus 1 month”
ExpiresByType image/x-icon “access plus 1 year”
Set Images Expiry
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
Set CSS Expiry
ExpiresByType text/css “access 1 month”
Now to enable the compression, uncomment this line of code in your default .htaccess file, so you’ll need to remove the # before php_flag zlib.output_compression on:
enable resulting html compression
php_flag zlib.output_compression on
Next, to set gzip compression into action, we’ll add these lines into the .htaccess file:
Inserting filter on all content
Inserting filter only on selected content types
Tackling some Netscape 4.x problems
BrowserMatch ^Mozilla/4 gzip-only-text/html
Tackling some Netscape 4.06-4.08 problems
BrowserMatch ^Mozilla/4.0 no-gzip
Scenario: MSIE masquerades as Netscape
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
Command for not compressing images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
Handling Proxies correctly
Header append Vary User-Agent env=!dont-vary
SOME USEFUL EXTENSIONS:
There are lots of extensions available for Magento, which enable fast caching and will help to significantly reduce page load time, but there are two which are considered to be the best options. One is Turpentine, which is based on varnish, and the other is Magento Full Page Cache. Both are extremely good extensions. Plus, the key advantage of using Turpentine is that its free, but if you’re looking to achieve the best impact in terms of performance, Full Page Cache has proved to be much better than Turpentine, but it costs around €349.
If you’re using large images on your site, chances are this is going to have a considerable impact on your performance, especially on image-heavy pages. I’d suggest serving your images via a CDN, such as CloudFlare or OnePica, which will mean your images are loaded from another server and will prevent unnecessary stress on your server when loading pages.
For more enterprise-level websites, I’d suggest using Cloudinary, which is an advanced image management solution that has the potential to reduce the load time associated with images considerably. Cloudinary serves all images via a fast CDN and also allows you to dynamically serve hi-res images and manipulate images on the fly via short URLs.
JPEGmini is another good resource that’s worth looking at for image compression.
I hope these simple steps will help you to substantially reduce your page load time. If you have followed this guide and put the steps into practice and measure your store’s page load time before and after the optimisation, you should see a clear improvement. Don’t forget to leave feedback in the comments section below – any further guidance would be greatly appreciated.
Here are a few other less major things that can be done to also help to improve performance:
Avoid unnecessary redirects (adding redirects to the .htaccess will impact page load speed – this is a mistake that lots of merchants make when they re-platform and apply manual page-level redirects)
Look at Memcache
Use a simple, clean page template as a base
Optimise your images
Also, I’d suggest looking at Varnish, Redis and Google Pagespeed as well, as these also represent great resources for improving performance.