13 Tips to Speed Up Magento Performance

speed up magento

Magento, owned by eBay, is one of the most widely used eCommerce platforms today that people to choose to grown their online business. In this post, we will discuss tips on how to speed up Magento performance to ensure you don’t lose any sales due to high abandonment rate or an unsatisfying user experience.

When it comes to choosing an eCommerce CMS or platform you have a lot of options. You could go with WooCommerce which is an extension of WordPress, Shopify, Volusion, and a number of other ones. The reason a lot of businesses choose Magento is because it is a very robust platform with a high level of functionality and customizability. It is highly scalable, meaning there would be no need to change to a different platform later on as you scale up.

According to BuiltWith, 16% of the top 100,000 eCommerce websites are using Magento, 22% if we also include Magento Enterprise. And WooCommerce comes in at a close second with 12%.

magento marketshare

eCommerce Marketshare Source: BuiltWith

According to Google Trends, the activity around Magento is still very high, since it’s official release in 2008. However, WooCommerce and Shopify have seen very rapid and consistent growth over the past few years so it will be interesting to see where Magento will be in the next five years.

google trends magento

Magento vs WooCommerce vs Shopify Source: Google Trends

Speed Up Magento

Magento and WooCommerce are both known for having issues with speed and their performance degrading over time. Making sure your eCommerce solution is running fast is one of the most important factors to your sales, SEO rankings, abandonment rate, and the shoppers overall user experience.

If an e-commerce site is making $100,000 per day, a 1 second page delay could potentially cost you $2.5 million in lost sales every year. – Kissmetrics

Follow these tips below on how to speed up Magento and keep it running fast to ensure return shoppers and sales.

Speed Up Magento Index

  1. Latest Version
  2. Content Delivery Network
  3. Utilize Caching
  4. Enable Flat Catalog
  5. Image Optimization
  6. Concatenate (merge) CSS and Javascript Files
  7. Enable Magento Compilation
  8. Clean Up Magento Database & Logs
  9. Fewer Extensions & Modules
  10. MySQL Configuration
  11. Update Indexes
  12. PHP Accelerators
  13. Choose Fast Web Hosting

1. Latest Version

It is very important that you are always running the latest version of Magento as updates generally contain bug fixes and performance improvements. There are three main steps when it comes to upgrading a Magento installation.

  1. Install a fresh version the Magento file tree (the version you are trying to upgrade to)
  2. Run the installer from the file tree on top of the outdated database (thereby upgrading the database)
  3. Move over themes and custom extensions from the old version to the current version.

Upgrading Magento is a little more work than upgrading WooCommerce or Shopify, but Magento has a good in-depth tutorial on how to fully upgrade Magento.

Magento also does a good job of notifying you of important updates that become available within your notifications/messages inbox (depending on which version of Magento you’re using.

2. Content Delivery Network

Implementing a Content Delivery Network (CDN) with Magento is one of the easiest ways to instantly see decreased load times. By doing this, you will ensure you are serving your assets (product images, javascript, CSS) from multiple locations around the globe so they are delivered faster to your shoppers.

CDN

KeyCDN has a very simple integration with Magento and Magento 2. Both can be setup with HTTP and HTTPS configurations.

3. Utilize Caching

There are many forms of caching that can be implemented with Magento. Many people have great success combining NGINX + APC + Memcache + Varnish caching.

Magento also comes with a built-in caching module as well, but 3rd party solutions seem to achieve better results. Make sure all Cache Types are enabled by navigating to “System” → “Cache Management”.

magento system caching

Browser Caching

Another form of caching you can leverage is browser caching. See the following snippets you can add to your .htaccess file, such as enabling Gzip compression and adding expire headers. Magento2 ships with an .htaccess file called .htaccess.sample which you can use to achieve the same goal. However, if you’re using an older version of Magento you may need to add these snippets manually if not already defined.

Gzip Compression

Gzip compresses web pages and stylesheets at the server level before sending them over to the browser.

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

Expire Headers

Expire headers tell the browser whether they should request a file from the server or grab it from the browser’s cache.

<ifModule mod_expires.c>
     ExpiresActive On
     ############################################
     ## Add default Expires header
     ## http://developer.yahoo.com/performance/rules.html#expires
     <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
     ExpiresDefault "access plus 1 year"
     </FilesMatch>
     </ifModule>

Page Caching

Page caching is one of the most powerful ways to speed up Magento. Load is taken off from the webserver by serving pages already visited before from cache, which makes it a lot faster.

There are a few page caching extensions available for Magento, we recommend one of the following:

LiteSpeed also offers a product called LiteMage which uses what they call “hole punching.” It designates certain areas of a page that can change and then the rest is served from cache.

litemage hole punching

LiteMage Hole Punching

4. Enable Flat Catalog

Magento uses the EAV model (entity attribute value) to store customer and product data. Enabling the flat catalog for categories and products merges product data into one table, thereby improving performance by responding to MySQL queries faster. If your eCommerce store has more than 1000 products, this can very beneficial.

  1. Navigate to “Stores” → “Configuration” → “Catalog.”
  2. Under “Storefront” change “Use Flat Catalog Category” and “Use Flat Catalog Product” to “Yes.”

magento flat catalog

    1. Click on “Save Config.”
    2. Clear the cache. The recommended way to do this is to delete everything from the /var/cache directory. You can also do it by navigating to “System” → “Cache Management” and clicking on “Flush Cache Storage” which is equivalent to deleting all the cache.

magento flush storage cache

5. Image Optimization

As we mentioned in a previous post on lossless image compression, on average 56 percent of a website’s page weight is made up of images. Optimizing your product images can dramatically increase the speed of your pages as this decreases their download times. You can compress them before uploading them using a tool like PhotoShop or there are a number of extensions you can use to auto-optimize them. For Magento version <2 users, the following extensions are available.

GTMetrix also has a Magento extension called GTspeed. It includes image optimization as well as CSS/JS concatenation and minification. Take a look at the difference on a stock Magento install.

Additionally, for Magento 2 users, the Image Optimizer for Magento 2 is an option.

6. Concatenate (merge) CSS and Javascript Files

Magento version <2 actually has a built in feature to concatenate (merge) your CSS and Javascript files into one file. This will reduce your total number of HTTP requests and in turn help speed up the loading of your pages.

  1. Navigate to “System” → “Advanced” → “Developer.”
  2. Under “JavaScript Settings” and “CSS Settings” change the dropdown to “Yes” and click on “Save Config.”

  1. After combining these files, you will need to clear the cache. Follow the process we mentioned earlier.

You can take this one step further by also minifying your CSS and Javascript using a Magento extension like Minify JS / CSS.

Magento version 2 users can also concatenate JS/CSS and also have the option to minify JS and CSS as well as bundle JavaScript directly from within the dashboard without the need for any additional extensions.

magento js optimization

magento css optimization

7. Enable Magento Compilation (Only Magento Version <2)

Magento has a compilation feature which has been reported to sometimes give up to a 50% performance boost. By default, Magento’s application files are searched in a certain order everytime the page loads, which results in a lot of filesystem reads. The Magento compiler reduces these reads by copying all of these files into a single include directory and also caches ones that are used more frequently.

  1. Navigate to “System” → “Tools” → “Compilation.”
  2. Click on “Run Compilation Process.”

Note: Before installing next extensions or upgrading Magento you have to disable this feature.

8. Clean Up Magento Database & Logs

By default, Magento keeps logs up to 180 days. This can result in your database growing quite large. You change it to something smaller like two weeks (14 days) to save space.

  1. Navigate to “Stores” → “Configuration” → “Advanced”→ “System” → “Log.”
  2. Under “Save Log, Days” change it to 14 days, or whatever you prefer.
  3. Click on “Save Config.”

You can also manually clean up your database by emptying the log tables.

  1. In phpMyAdmin select all of the log_% tables and select “Empty” from the drop-down box.
  2. Click on “Yes” when it asks you if you really want to TRUNCATE the tables.

9. Fewer Extensions & Modules

Just like with WordPress and any other platform, the more extensions you have running the more HTTP requests there are, as well as additional CSS and Javascript files having to load. It is best to keep your Magento install down to as few extensions as possible.

You can also disable modules that you don’t use.

  1. Navigate to “Stores” → “Configuration” → “Advanced”→ “Advanced”.
  2. On the modules you just need to select “Disable” from the drop-down box and click on “Save Config.”

magento disable modules

10. MySQL Configuration

MySQL has its own “query cache” that it uses in Magento to help generate dynamic pages and content while improving performance. These are some recommends settings for your my.cnf file.

query_cache_type = 1
query_cache_size = 32M
query_cache_limit=2M

And also a recommended setting for php.ini.

php_value memory_limit 512M

11. Update Indexes

Magento updates indexes on every object store by default, but in some cases manual updates are required. Indexes are used to speed up MySQL queries.

  1. Navigate to “System” → “Index Management.”
  2. Select all of the indexes (or the ones you want to update), choose “Reindex Data” from the dropdown and click “Submit.”

magento reindex data

12. PHP Accelerators

Using a PHP accelerator is another form of caching. They increase performance of PHP scripts by caching them in their compiled state. You can use a PHP accelerator like APC, ZendOptimizer+ or Xcache.

13. Choose Fast Web Hosting

And last but not least, choosing a reliable and fast web host can be one of the most important decisions you will make when trying to improve Magento performance. We recommend staying away from cheap shared hosting as they tend to overcrowd their servers and you will end up sharing resources between hundreds of people. We suggest going with a VPS like Digital OceanLinode, or Vultr. The reason is because you will be in complete control of your resources. And if you aren’t as tech savvy or don’t want to manage your servers via CLI, ServerPilot is a great control panel alternative which works with Magento and the VPS providers mentioned above.

Summary

As you can see there are many ways you can speed up your Magento eCommerce site. From implementing a CDN to caching, enabling flat catalog, image optimization, merging CSS and JS files, using the Magento Compiler, and cleaning up your database. Also having a good web host is equally important.

Do you have another way to speed up Magento that we missed? We would love to hear about it below in the comments.

Related Articles

13 Tips to Speed Up Magento Performance was last modified: June 6th, 2017 by Brian Jackson
  • flamefox

    Thanks for valuable tips! It’s true that one should do a mix of things to achieve great results in Magento optimization, it’s not enough just to have a good hosting or optimized images.
    You’ve mentioned caching. I used to prefer default Magento cache as I didn’t really understand how it works or what FPC extensions do. I’ve recently learned quite a lot about it, this article helped me in this https://blog.amasty.com/amasty-research-full-page-cache-vs-varnish-cache/
    Moreover, now I’m using a special extension. You’ve mentioned a few, I didn’t actually tried them. I’m using this one https://amasty.com/magento-full-page-cache.html

  • Aashni Joseph

    Thanks for sharing magento speed optimization tips. U have missed Ajax loading. This is one of smartest speed optimization techniques deployed by majority of Magento websites. AJAX, which is collection of programming techniques such as XML, DHTML, CSS & JS files, displays the cached paged initially. Only when the user performs some action like scrolling the mouse, it displays the remaining contents of the page. To know more… https://readymag.com/Magento/Top6-Magento-speed-optimization-tips/

  • Carol Robertjoan

    Great post, thanks for sharing….Alternative, if you would like to find more about magento ecommerce platform, contact our Openwave Computing NYC experts today for support…

  • TrungNguyen

    Thank you for your sharing!
    It’s very useful.
    Beside some manual ways, we can use Magento extensions to speed up Magento sites
    For example, Defer JavaScript extension also reduces loading time because it defers JavaScrip loading till the last moment after loading all HTML and CSS

    http://bsscommerce.com/magento-defer-js-extension.html

  • I would like to mention two more factors needs to consider for magento webpage loading speed optimization, they are Http Requests and ajax loading. To know more checkout the techniques here: goo.gl/p6Zkbo

  • very good , https://www.audiobuy.com.au uses these tools , the best we can get is about 3 seconds load time.

  • Crackor Squad

    great information , greets from http://www.crackorsquad.in/

  • Jason Huebel

    If I enable the flat catalog options, are those settings irreversible? If I put them back to “No”, will my original settings be restored?

    • Jason Huebel

      I’ll answer my own question. Yes, you can revert back.

  • We prefer Opcache over APC, XCache or eAccelerator because of greater support and improved reliability. Moreover, PHP community is going to support OpCache in the coming versions so that has better support in future. Overall you have shared a very nice tutorial on speeding up the Magento store.

  • Alex Silenko

    It would be good to mention that we can use additional layer of caching. For example when it’s not possible to use FPC, but we still can put some “hard” part of the page into custom cache.

  • Jeeva Rathinam

    When i enable merge js and merge css, my theme template completely collapsed.

Share This