Increase Magento Speed and Performance

14 Dec

Magento is known to be a quite ‘heavy’ ecommerce CMS system that will run slowly if the right settings are not applied to it. The settings to increase the speed and performance of Magento for faster page loads are not obvious and are, in fact, often missed by even experienced web developers if unfamiliar with the Magento platform.

There are over a dozen methods that one can use to increase Magento performance and other PHP based CMS systems, that range from settings within Magento, all the way to optimization of server or hosting settings. Yet, the most commonly missed methods to speed up Magento, are those that are also relatively the easiest ones, and those that increase the Magento page-load speed significantly. The right Magento hosting company may have the correct server settings, but the settings that need to happen within your Magento settings are often not documented. Here I will cover the top 5 of these methods for better Magento performance:

Enable Flat Data Products & Categories

Magento Flat Products / CategoiresWhether or not you should enable the Flat Data of Products and/or Categories varies depending on your Magento website structure.

First, it may be important to understand the concept of ‘Flattening’. Similar to when creating graphics in Photoshop, .PSD files, you will have several layers, such as the layer for the background, the layer for the text, a layer for each graphic object you create and would like move around individually. If you were to save the .PSD file, it’s size would be rather large, because it contains all the layers, settings of each layer and so on. If you were to now ‘Flatten’ the layers, or export its content as a .jpg file, the resulting file size would be much smaller, yet it would look the same. The feature that is lost, is that you can no longer make changes to it ‘quickly’ because all the options and layers would be lost.

In the Magento Flat Product/Category concept, the .PSD layers correspond to the Database tables of each object, product or category. A database table is required for each attribute, such as price, descriptions, name, weight, color and many other attributes that apply to your products/categories. If you have only dozens of products with many attributes, or have a few hundred products with only a few attributes/attribute variations, then flattening the products/categories may not impact the site speed significantly. On the other hand, if your website contained almost 1,000, or possibly several thousands of products, then it is almost always recommended to flatten your products. If these products are spread across multiple dozens of categories (and products aren’t duplicated across these categories), then flattening these categories would be suggested as well.

After completion of the Magento data entry and prior to launching, consider whether or not to enable the flattening of product/category data. Find the options in System->Configuration->Catalog.
Merge CSS and JS Files

Merge CSS and JS files in MagentoThe merging of CSS and JS files is a common practice done to increase site speed, not only on Magento but on all websites in general. The idea is simple, that a website only has to load one CSS and JS file, not several, thus making the page load faster.

Of course this can be done manually with help of an experienced web developer, but to save time, Magento has its own settings for this in System->Configuration->Developer.
Magento Htaccess Gzip, Mod_deflate, Performance Settings

A quite noticeable impact on Page Speed occurred after the correct settings were applied in the .htaccess file of Magento’s Root install folder. The Magento .htaccess file comes with pre-described settings that one must simply ‘uncomment’ to enable, which depends on your hosting company’s capabilities, or your servers VPS setting’s.

Start by opening your Magento root .htaccess file, and finding the settings that apply to your hosting/VPS features. Despite the deterring of using unoptimized Hosting companies for performance based platforms, you will still find those ‘specific’ settings if hosting on those platforms – which would then likely be the only settings you could apply. In the below lines of your .htaccess file, you would need to ‘uncomment’ line 12 for GoDaddy or lines 21 and 22 if hosting on 1and1.
############################################
## GoDaddy specific options

#   Options -MultiViews

## you might also need to add this line to php.ini
##     cgi.fix_pathinfo = 1
## if it still doesn’t work, rename php.ini to php5.ini

############################################
## this line is specific for 1and1 hosting

#AddType x-mapp-php5 .php
#AddHandler x-mapp-php5 .php

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

If your site is hosted on a Magento / PHP optimized hosting or you’re VPS is setup for the features, then you can go ahead and uncomment these features in your .htaccess file, which should be:
#php_flag zlib.output_compression on
# 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

Also uncomment all the BrowserMatch, SetEnvIfNoCase and Header settings, which are set right after the above Filter rules on line 86, 89, 92, 95 and 98.

Assuming your Magento website is still in development, you shouldn’t require the clearing of your Magento cache in the admin (since this would be set to No-Caching’), but it may still be suggested empty your Magento var/cache and /session folders probable page speed difference.

Compiling Magento

Magento CompilationMagento Compilation is an important step to take after development completion of a Magento website. What compiling will do is take all the active scripts in your Magento’s core structure and bring them to the ‘front’ for faster website speed. To better imagine the process: Similar to the above description of flattening products/categories, compiling would be the equivalent to flattening of Magento’s file-system in your project.

It is important to know that after compilation, you can’t upgrade your Magento store, install or change core/extension settings, nor change core files or features within Magento’s core folders or those present within template files. Doing so may result in errors or problems in functions. To avoid that, simply de-compile before making any of the above changes, and simply compile again after. Both the compiling and decompiling can found in the same settings page at System->Tools->Compilation.
Caching Magento via Cache Management

Magento Cache ManagementOf course, when all the settings are in place and your site is ready to launch production, cache your Magento site via System->Cache Management

For most Magento sites, caching only the first 4 cache types will be recommended, which, on the Magento version 1.7 and up, are Configuration, Layouts, Blocks HTML output and Translations.

Whether to cache the remaining 4, which are Collections Data, EAV types and attributes and 2 for Web Services Configuration depend on your sites data and structure as well as possible features used that interact with those data types. Caching them when not needed may have negative impact on your website speed overall or in certain sections. To determine whether to cache or disable caching for EAV Types and Attributes, you could test the duration of adding a product to cart, or the page load time of visiting your shopping cart with a few products added. The Collections Data could be tested similarly, while logging into or creating an account on the Magento store front-end, and doing the same test with the shopping cart or page load speed during checkout.
Other Magento Performance Settings

The above settings will help increase the performance for the average Magento websites, but for those who are more familiar with servers can take several extra steps to increase the speed and performance even more. Server caching extensions, such as APC and eAccelerator do have a place within Magento’s configuration file, as well as other server tricks that can be used to increase the performance. Feel free to subscribe to know when these features, as well as tutorials to test and optimize performance for Magento and WordPress are posted.

No comments yet

Leave a Reply

Current day month ye@r *