Magento 2 Performance Optimization

In Magento2, performance optimization is the key and one of the most important factor to make our store more faster and better in terms to reduce the page load time. So a faster online website is always the ideal choice of customer to visit and make a quick comfortable purchase. It is always best to have a good customer base who prefer our stores to make orders which helps in multiple factors like to increase the conversion rate and other ecommerce revenue things.

Magento 2 provides fantastic features as a great platform with following results:

  • Faster catalog browsing
  • Quick comfortable order process
  • Quick page rendering to view using cache mechanism
  • Customizable quick checkout

Quick Steps to Optimize Performance:

  • Step 1: Merge CSS and JS Files
  • Step 2: Caching
  • Step 3: Content Delivery Network
  • Step 4: Enable Compression
  • Step 5: Image Optimization
  • Step 6: Reduce Server Response Time
  • Step 7: Regular Magento Updates
  • Step 8: Optimize custom collections and SQL queries to get only necessary results
  • Step 9: Apply database table indexes to make faster execution at Database level

Step 1: Merge CSS and JS Files

In this step, we need to merge and minify the CSS and javascript files which means we need to make a single CSS and single javascript file for the fast loading of web page.

Merge Javascript Files:

  • Go to Admin -> Stores -> Configuration -> Advanced -> Developer -> JavaScript Settings
  • Set Merge JavaScript Files to Yes
  • Set Minify JavaScript Files to Yes

CSS File

  • Go to Admin -> Stores -> Configuration -> Advanced -> Developer -> CSS Settings
  • Set Merge CSS Files to Yes
  • Set Minify CSS Files to Yes

When we are done with setting, just click “Save Config” button and flush cache to see the changes.

Step 2: Caching

In the Admin -> System > Cache Management

Step 3: Content Delivery Network

Content Delivery Network (CDN) is a special system which is used to connect all the cache servers. In addition to supported geographical proximity, CDN will take over the delivering web content and fasten the page loading. If you are using CDN, you need to make sure the following configuration changes:

Go to Admin -> Stores -> Configuration > General > Web > Base URLs (Secure)

Step 4: Enable Compression

We can follow the resources to enable compression. Let’s change the nginx compression directives from:

gzip_types: text/plain application/x-javascript text/javascript text/xml text/css image/x-icon image/bmp image/png image/gif; to gzip_types:;

Step 5: Image Optimization

The image is an important content to make our store’s performance better and more faster. So we need to reduce the image size which can improve the load performance of website. Compressing image is needful when uploading any image to website.

Step 6: Reduce Server Response Time

Magento 2 supports built-in cache mechanism which makes site’s response time quite good with approx time as 0.5s. Once you add varnish to our Magento store, it makes our Magento 2 a superfast speed web page which loads in around 0.1-0.2s.

Go to Admin -> Stores -> Configuration -> Advanced -> System -> Full Page Cache, transfer Caching Application to Varnish Cache.

Open Varnish Configuration section in admin and make the necessary changes in the settings:

Step 7: Magento Updates

If it is about security patches and version updates, we need to do it on regular basis to optimize the site performance.

Step 8: Optimize custom collections and SQL queries to get only necessary results

It is necessary to make custom developed extensions optimized in terms of looping over only needed data and using any data as optimized. Only call needed SQL queries and select only needed columns.

Step 9: Apply database table indexes to make faster execution at Database level

To make the read operation faster, we need to apply indexes on database table columns.

Hope this helps you guys!!

Leave a Reply