Processing... Please wait...

Product was successfully added to your shopping cart.

Speed Up Magento and Boost Performance in 20 Proven Steps

20 proven steps to increase magento speed and performance 20 Proven Steps To Increase Magento Speed and Performance

Do you want to speed up Magento performance? Of course you do! And you are not alone.

The most popular (according to BuiltWith) eCommerce platform might be slow. That is no surprise – it was built with scalability and flexibility in mind, not speed.

Here are 20 proven steps that will help you increase Magento speed & performance:


20 Ways to Speed Up Magento


  1. Optimize TTFB
  2. Minimize latency
  3. Optimize Server configuration
  4. Choose fast hosting
  5. Optimize VPS for Magento
  6. Audit Magento code
  7. Optimize Start Render time
  8. GZIP compression
  9. Domain sharding
  10. Enable browser caching
  11. Prioritize above-the-fold content
  12. Remove render-blocking CSS and Javascript
  13. Reduce the size of visible content
  14. Put above-the-fold content first
  15. Optimize document complete time
  16. Serve optimized images
  17. Sign up for CDN
  18. Optimize fully loaded time
  19. Don't abuse jquery.ready
  20. The less third-party JS the better



There are ways to make your Magento site fly and I will show you how to do that in a sec. But first let us define what we will use to measure site speed.



How to Measure Magento Speed


When a browser loads a web page it does certain actions:

  • It receives html data from a server.
  • It analyzes data and loads external files you might have on the page (CSS/JS/images/fonts etc).
  • It then builds what's called a DOM (Document Object Map).
  • It renders the page (puts elements on the screen).

The detailed overview of how a webpage gets loaded and displayed can be seen on varvy blog.

We can define 3 time periods that measure how quickly a webpage loads:

  • Time to first byte (TTFB) or server response time: the time from when a user clicked on a link or typed in a site URL until the first bit of information from the server arrived.
  • Start render time: the first point in time that something was displayed to the screen. Before this a user was looking at a blank page.
  • DOM complete or document complete time: the point in time when the browser considered the page loaded (onLoad javascript event fired). All the content has been loaded except content that is triggered by javascript execution.
  • Fully loaded time: a webpage is loaded and no network activity is performed by a web browser.

Definitions are taken from webpagetest.org.

TTFB < Start render < DOM complete < Fully loaded

The waterfall chart The Waterfall Chart

The most important time in my opinion is the start render time. The quicker you show a user that something is happening after he requests a webpage the faster he thinks the site is.

There are 3 main time limits that describe user perception of how quick a web application is [study]:

  • 0.1 second response time – a user feels that a system is reacting instantaneously.
  • 1.0 second response time – a user notices the delay, but it doesn't bother him
  • 10 second response time – the limit for keeping the user's attention focused. For longer delays, a user will want to perform other tasks while waiting for the computer to finish.

We want to keep start render time around 1s to make a user feel a web site is fast.


Optimize Time to First Byte


Server response time or time to first byte (TTFB) consists of the time a browser's request goes to the server and server response goes back to a browser (latency) and the time a server generates HTML.

Google recommends having TTFB around 200ms. 1s TTFB is considered bad.

To lower TTFB you need to work on latency, server configuration and Magento codebase. Here are my in-depth tutorials on how to optimize TTFB for Magento 1 and Magento 2.


1. Minimize Latency


Host your website as closer to your main audience as possible. If you sell shoes in London, do not sign up for hosting in Japan. Common sense.

Do not think that SSL will impact your TTFB much. SSL negotiation time is negligible but the SEO benefit is obvious.


2. Optimize Server Configuration


Optimizing server configuration includes choosing the right hosting and setting up server software.


2.1 Choose Fast Hosting


A Magento site can't run on $5/mo shared hosting. If you want good TTFB and start render times, sign up for VPS or Magento-optimized hosting – Nexcess, Magemojo and others. Do a Google search and see what others recommend.


2.2 Optimizing VPS for Magento


If you plan on running VPS or a dedicated server, you need to optimize server software and MySQL database.

Options to choose your server setup are endless and depend on your expertise. You can configure NGINX, Apache, Varnish, HHVM, php-fpm, Redis, memcache.

I will list possible solutions for high magento performance:

  1. Varnish + NGINX + PHP-FPM + Redis
  2. Varnish + NGINX + HHVM + Redis
  3. Use PHP7 with Magento 2 or PHP7 + Inchoo patch with Magento 1.x
  4. Host webserver and database on different servers
  5. Use MySQL master-slave replication for separate reads and writes


2.3 Server Performance Hogs


I will list common server misconfigurations that slow Magento sites:

  • Disabled MySQL query cache. Modern MySQL servers come with query cache disabled by default. Enable it – it will speed up Magento significantly.
  • Slow disk I/O. Make sure your host provides you with SSD (solid state disk) storage.
  • RAM shortage. When the system runs out of RAM, it puts data on disk (swap), making things slow.


3. Optimize Magento Code


Your Magento site php code and template files are the main reason for poor server response time.

First, you need to profile the code and identify parts that slow site down. Magento comes with a built-in profiler you can use. You can use third-party extension Aoe Profiler or sign up for NewRelic application performance management tool.


3.1 Magento Code Performance Hogs


  • Observers that run on every page request
  • Poorly written template files
  • A slow MySQL query(s) somewhere

Here is a detailed tutorial I wrote on how to optimize TTFB with Magento profiler.


3.2 Poorly-written Magento Code


An example of bad Magento code that I encounter too often:

Loading Magento models inside a loop. That happens in product list templates; people iterate over product collection and load the product model every time:

foreach($collection as $product){
  $product = Mage::getModel('catalog/product')->load($product->getId());

Don't do that. Better construct your collection to have all the data you need. Magento model loads are expensive.


Optimize Start Render Time


Start render time (SRT) is the first point in time when a user sees the content after requesting the webpage. It could be a background image or some text blocks, but from that time on he knows something is happening. Start render time in my opinion is one of the main factors by which a user judges how fast the site is.

According to the 3 main time limits [study] I mentioned earlier, we need to keep the start render time to around 1s.

SRT consists of:

  • Time to first byte (TTFB)
  • Time it takes to download a page HTML
  • <head> section parsing and downloading resources (JS/CSS external files) a browser finds there
  • Initial layout calculation

After we understand what start render time is, we have options to optimize it.


1. GZIP Compression to Shrink Page Size


Compress your html page so that a browser has fewer kilobytes to download. Enable gzip compression on the server side – see instructions for your web server. Confirm you have gzip enabled by this online testing tool.


1.1 NGINX GZIP Compression


NGINX example configuration to enable gzip:

http {
        gzip on; 
        gzip_disable "msie6";

        gzip_vary on; 
        gzip_proxied any;
        gzip_comp_level 6;
        gzip_buffers 16 8k; 
        gzip_http_version 1.1;
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;

You need to restart NGINX for the changes to take effect.


1.2 Apache GZIP Compression


When running Apache you can enable gzip by changing .htaccess file inside your Magento root folder:

<IfModule mod_deflate.c>
  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
  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

Use online tool to test if gzip is on.


2. Domain Sharding


Domain sharding is splitting external resource files (JS/CSS/images etc) across multiple domains. Why bother? Because a browser can download files in parallel but has a limit per domain. For example Chrome can do 6 concurrent connections.

If we can split images, js, css files across multiple subdomains, we can make a browser download resources a lot faster.

UPDATE: domain sharding is not needed when you use HTTP/2. And the use of HTTP/2 is recommended.


2.1 Domain Sharding in Magento


Magento supports domain sharding by default and it is easy to setup:

1. First create subdomains:

  • skin.domain.com
  • media.domain.com
  • js.domain.com

and point them all to the same IP and file folder your main domain is pointing to.

2. Go to Magento backend main menu System > Configuration > Web and set Base Skin URL, Base Media URL and Base Javascript URL for unsecure and secure (if you have one) links.

3. Flush cache and confirm your resources are now served from subdomains.


3. Leverage Browser Caching


A browser can cache files for faster access. You can take advantage of this to lower the start render time.

Configuration depends on your server:


3.1 Leverage Browser Caching for NGINX


Add this inside server directive:

        location ~* \.(js|css|png|jpg|jpeg|ico|gif|pdf)$ {
              expires 300d;
              add_header Pragma public;
              add_header Cache-Control "public";


3.2 Leverage Browser Caching for Apache


Add this into your .htaccess file:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"

as taken from Gtmetrix.


4. Optimize Above-the-fold Content


Above-the-fold content is the part of a page that you see before you scroll down. It is also referred to as visible content.

Prioritize visible content – load and display it as quickly as possible.

How do I optimize above-the-fold content? Here are some tips:


4.1 Remove Render-blocking CSS and Javascript


The less time a browser spends parsing <head> section of your webpage the better. Ideally, only JS and CSS needed to display above-the-fold content should be put in between head tags.

Go through your css files and identify rules that are applicable to visible content. Inline those rules. Do the same for javascript.

Here is a detailed tutorial on how to optimize CSS delivery and an extension to defer Javascript parsing (remove render-block Javascript).


4.2 Reduce the Size of Visible Content


The less visible content a browser has to download the better. Make sure images are optimized. Remove any content that is not needed.


4.3 Put the Above-the-fold Content First


Analyze the page HTML and make sure visible content goes first.

Refer to this tutorial on how to prioritize visible content.


Optimize Document Complete Time


Besides start render time and first byte time improvements, there are a few things you can do to decrease document complete time:


1. Optimize Images


UPDATE: for more details on how to optimize images refer to my other post.

The less time browser needs to download images the better.

There are various online tools that help you optimize images. Image Optimizer, Compressor.io, TinyPNG are just a few.

If you are familiar with linux command line, then you can bulk optimize jpegs, pngs with jpegtran and optipng. Jpegtran is part of libjpeg package.

Useful oneliners to bulk optimize images for Magento site:

find ./skin ./media ./js -type f -iname '*jpg' -exec sh -c 'jpegtran -outfile "{}.out" -optimize "{}"; mv "{}.out" "{}"' \;
find ./media ./skin -iname '*.png' -exec optipng -o5 -keep -preserve '{}' \;


2. Use CDN


Content Delivery Network (CDN) is a web service to host your Magento site external resources: CSS/JS files, images, fonts etc. It aims to serve those files at lot faster than you can with your own server.

Magento supports CDN by default, no extensions needed. Go to System > Configuration > Web and set secure/unsecure URLs for media, skin, js resources.

There are many CDN providers to choose from: MaxCDN, KeyCDN, Amazon CloudFront and others.


Optimize Fully Loaded Time


If you have done start render, first byte and document complete times optimization, there is the final step – fully loaded time improvements.


1. Don't Abuse jquery(document).ready


Choose onLoad events carefully. Don't put CPU intensive tasks in jquery.ready – it slows down page loading.


2. The Less Third-party Javascript the Better


Examine what third-party javascript files you add to your Magento store. Do you really need them?

Well known JS code like Google Analytics, Facebook is all optimized and its performance impact is negligible. Others – use with caution and always test.


Implement Magento Performance Tests


Include performance benchmarks into your workflow. Every time you add an extension from Magento, connect or roll out new feature – see what impact it has on site speed. Does it slow Magento? Debug or go for another module.

A few tools that help you speed up Magento and evaluate its performance (free to use):

1. webpagetest.org – provides you with page-loading waterfall charts and tons of other useful information. Supports mobile browsers.

2. Google Chrome Timeline – helps you analyze frontend performance. Takes a little time to get used to, but once you are familiar with it, it gives you valuable insights into why your Magento is slow.

3. Google PageSpeed Insights – an online tool that tells you what to do to boost site performance. Work on suggestions by Google and improve Magento speed.


Run a Magento 2 store? Check out 3 simple fixes to improve M2 performance.



Strugle with slow Magento! We can help! Fill out the form below.


Like the article? Share:


Other articles you might be interested in:

  1. Magento 2 TTFB (Time To First Byte) Optimization
  2. How to optimize CSS delivery on Magento website
  3. Magento 2 slow - reasons and 3 simple fixes
  4. Magento 2 Performance Optimization - 90%+ PageSpeed
  5. 5 reasons your Magento backend is slow


If you find this post interesting do not hesitate to sign up for our newsletter and join the 872 people who receive Magento news, tips and tricks regularly.

Thank You!



8 thoughts on “Speed Up Magento and Boost Performance in 20 Proven Steps”
  • deep

    wow. awesome contents

  • Randy de Decker

    Good article that I've bookmarked. I've implemented a lot of these actions above, but good to know there are still some improvement points left.
    I agree with Steve that HHVM should not be used with M1. And a good FPC decreases load times substantially, but offcourse does not improve the uncached pages loadtime.

  • Fayyaz Khattak

    Well, I have used Cloudways Magento Full Page Extension powered by Amasty to speed up the Magento performance. I avoided using heave theme and used trusted extensions to accomplish some tasks on my ecommerce store. The store now loads within 2 seconds, and I am delighted with the reviews of my customers about the performance of the store.

  • Alexander

    Magento is an ecommerce heavy open source platform. It is a big problem for you when your magento store runs slowly and at that time you have to setup it properly.

  • Tej singh

    Tottaly agreed to all the above points foe increased magento page speed but one point we are forgetting is what happens if we clear cache in middle of the day when customers are actually hitting the site, best solution is to have cache warmer that quickly crawls and puts the page back under cache.

  • olivedev

    Some great tips for optimizing Magento's speed. Few more things that you can do to tune the performance are: install Turpentine – Varnish Cache plugin and configure Memcached with Magento 2. You will notice a significant increase in speed.

  • Konstantin Gerasimov

    @Steve - thank you for your comment

    what did you mean by " I’d take care with infrastructure suggestions that are outside Magento’s requirements ( so no HHVM, > 5.4/5/6 on Magento 1.x and so on ). Don’t want to get sued!"?

    I run HHVM with magento 1.x with no problems

    master-slave setup for magento is a great way to speed things up - master for writes, slave for reads - magento supports separate reads/writes databases.

  • Steve Holdoway

    Great to see a well thought out list rather than the usual regurgitated posts from a decade ago! However, I do disagree with a few of these, and have a few suggestions ( well, what do you expect from a grumpy old bugger like me! )...

    - If you split database and web server then you've not only added a new point of failure ( and potential performance problems ), but you now have to build up / tear down TCP connectivity to extract data from the database, rather than ( with a properly configured server ) just pick it out from local memory.

    - it's very unlikely that your site will ever become busy enough to require a master / slave database setup. Also remember that this will slow things down if you're not very careful indeed.

    - there are many more file types that can take advantage of browser caching.

    - domain sharding is pointless with use of a CDN... just hand the heavy lifting over to them and let them sort it out.


    - what about http2?

    - I'd take care with infrastructure suggestions that are outside Magento's requirements ( so no HHVM, > 5.4/5/6 on Magento 1.x and so on ). Don't want to get sued!

    - tuning of the OS?

    - and finally what about caching!