5 Ways to Enhance the Performance of Your Magento Store
According to popular statistics, 40% of the online shoppers abandon a website that takes over 3 seconds to load a particular page. It’s been observed that 47% of the online shoppers expect the online shopping site to load within a time frame of 2 seconds or less than that. To match the high expectations set forth by your consumers, you will need to reduce the loading time and optimize the performance of your Magento store. A well optimized and functional store helps capture the audience and retain them for a long time.
When you set out to develop a website, you don’t really look at optimizing the speed initially. Your first concern is ensuring the design and functionality of the website is perfect and matches the need of the store. You will also work on adding products, pricing them and working your way through the CMS page ensuring there are no errors. It is only when you are done with design and development of your store that you think about optimizing its performance to cause efficiency and engagement. While a good hosting solution helps improve performance of your website, it is not the only thing that you need optimize. There are other verticals too that need your attention so as to enhance the speed of the website, and improve its overall performance.
Amend the .htacess File
If you want to improve the performance of your Magento store then one of the best ways to do so would be tweaking your .htaccess file. There are two methods in which you can modify the file and enhance the performance
1. Compress the Output Files
The output sent to the web browser should become your main concern when you are optimizing the performance of your website. It is important to compress those files that you consider heavy. Mod_deflate is a module that is facilitated across servers and it helps compress text files and other output files. These compressed files are uncompressed by the server just before they are placed on the customer’s browser. If you wish to facilitate this tweak for .htaccess, you will need to uncomment a few lines.
Deflate filter is the code that is generally used for compression of files.
The code below will direct the browser to compress the documents present within a container
<if module mod_deflate.c>
##enable the compression of .htaccess files
#Insert a filter across the content on this page
In case you don’t want to insert the filter on all the content types, you can select the file types and add filter to it
<Directory “Directory Name”> AddOutputFilterByType DEFLATE FileType
There are certain browsers which are unable to decompress the compressed files at the customer’s end. For such browsers, it is important to avoid compression. no-gzip is an excellent way to ensure no compression is formed on such browsers. To enhance the performance of the website, it is suggested to use a combination of gzip-only-text /html with no-gzip.
An example of such browsers which don’t support compression is NetScape Navigator version 4.x. It is best to switch off the deflate filters for such browsers. Here is the code for removing filters on such browsers.
BrowserMatch ^Mozilla/4 grip-only-text/html
BrowserMatch ^Mozilla/4\. 0 no-gzip
BrowserMatch \bMSIE ! no-gzip ! gzip-only-text/html
Note: DEFLATE filters by rule should always follow the resource filters like PHP or SSI
Once the compressed files reach the customer’s computer, it needs to be decompressed. Mod_DEFLATE module offers an internal decompression filter using which you can easily code for decompression of these files.
<Location / name > SetInputFilter DEFLATE
2. Utilize Web Caching
It is seen that certain file types never change even when they are accessed n number of times. Best examples of such file types include images and css. It is best to use web caching behavior in order to optimize the performance of your website in such instances. If you want to utilize web caching, setting up the far-future expires headers will come to your help. Once you do that, your customer will observe optimized performance when they revisit a particular page as it doesn’t have to be redownloaded.
<If module mod_expires.c>
## Add default Expires header
ExpiresDefault “access plus time period”
Rebuild Indexes Before Going Live
If queries on your storeare loaded fast, it automatically improves the performance of your store. In order to improve the efficiency of your queries, Magento loads some of the data into special tables.
While designing your store, there are times when you add or delete data thus creating gaps in your indexes. It is important to refresh and realign the indexes so that whenever they are called on using queries, your store is ready to send the data out.
How to refresh the indexes? Here are two possible solutions for this issue.
Using Admin Dashboard
Go to System> Index Management>Select All>Select Reindex Data and click on Submit
Using Command Line
Magento version 1.4 and higher include command line. You will find the shell tools to be used for refreshing the indexes within Magento_Root/Shell/directory.
This directory holds the same functionalities that have been observed in the Admin panel
Usage php –f indexer .php –[options] — status <indexer> This shows the status of the indexer — mode <indexer> Shows the index mode of a particular indexer or all indexers — mode- realtime <indexer> Update the indexer on save — mode- manual <indexer> Updates the indexer manually — reindex <indexer> reindexes the selected data
info Shows the different indexers
reindexall Reindexes all the data written down as indexers
If you want to refresh all the indexer data, then you just need to write down this code
$ php –f indexer .php reindexall
Rely on Caching
One of the favorite solutions of all the websites and stores, to improve the performance, is caching. When you are going through the process of development, you tend to switch off the caching of your store. But, before your website goes live, turn on the cache. With the cache enabled, performance of your website improves drastically.
What all is cached when you enable caching on your store? XML files, both related to configuration and layouts are cached so that the user need not redownload them. Apart from these files, you will see that HTML blocks, translations within an array and data collections related to the store and store view are also cached in order to optimize the performance of the website.
Incorporating Flat Catalog
EAV is an integral element of Magento which is majorly used to store data related to customer, product as well as the different categories that you have uploaded to the store. There are a wide range of attributes associated with EAV model. The only hitch of using an EAV model is that your data is stored into multiple number of tables instead of using up a single large table which translates into complex SQL queries, and a less optimized store.
In order to improve functionality, you can incorporate the flat catalog feature to your store. With this feature you can add up all the attributes for a single store in a single row thus providing efficiency to the SQL queries and improving the performance of your store. If you have more than 1000 SKU points associated with your store, then you can gain performance benefit from incorporating flat catalogs
To enable this within your back-end you need to
• Go to System>Index Management. Here you will need to ensure that “product flat data” as well as “category flat data” are built in
• Go to System>Configuration>Catalog>FrontEnd. Click on yes to use the flat catalog category. In case you want to use flat catalog product, click yes to enable
Optimize Using Mage Compiler
Magento version 1.4 as well as 1.3.2.x have incorporated the feature of Mage compiler which attributes towards improving the performance of the Magento store.
Let’s first understand how the store reacts when a URL is being requested. Whenever the store receives a request, it starts looking up all the directories available on the store’s database in a sequential manner.
With these directories in place, you can easily extend and modify your store to suit your requirements. Let’s say you wish to change/modify a class, add the code to app/code/local/ and you will see that this code will be compiled before the core code.
This results in a complicated affair with compilation. Your store tends to check every I/O request causing the site to slow down. That’s why you need the Mage compiler. With this compiler you are able to create a single directory for all class and code that fall under the bracket of a single app/code. This way Magento needs to check out only a single directory which eventually saves a lot of time.
Once installing and customizing the codes are done with, you need to go ahead with compilation. You can enable the compilation using the admin panel or command line.
To enable using admin panel go to
System>Tools>Compilation>Run Compilation Process
To enable using command line
$ php –f compiler.php help
Usage: php –f compiler.php — [options]
State Shows the state of your compilation
Compile Runs the whole compilation process
Clear Removes all the compiled files along with the compiler included path
Enable enables the compiler included path
Disable disables the compiler included path
The script for this syntax is located within the MAGENTO_ROOT/shell directory
Deepa Ranganathan, technical writer at Semaphore Software, advocates open source technologies. Her in depth knowledge of Magento matched with her flair for writing helps her articulate different solutions that might help. If you wish to hire Magento developers you can reach out to her.