How to speed up your Magento 2 store and increase performance

Magento 2 speed optimization is a quite important step to reach good traffic to your store.

1. Enable all Magento caches

System->Cache Management->Select all-> Enable-> Submit


2. Enable JS & CSS optimization.

Css and JS file help your frontend look better. However, they are one of the core factors that slow down your site speed. Luckily you can minimize influence in magento 2 by enabling JS & CSS optimization

To enable JS & CSS optimization:
Go to Stores -> “Configuration” in “Settings” Section -> “Developer” in “Advanced” Tab -> Section “JavaScript Settings” (Fields “Enable Javascript Bundling“, “Merge JavaScript Files“, “Minify JavaScript Files” change to “Yes”)

Enable JS & CSS optimization.

Go to Stores -> “Configuration” in “Settings” Section -> “Developer” in “Advanced” Tab ->-> Section “CSS Settings” (Fields “Merge CSS Files“, “Minify CSS Files” change to “Yes“)

Enable JS & CSS optimization. 2

3. Images Optimization

There are 2 things that need to be kept in mind:

A. You image must be compressed.
B. Product Image should use JPEG format
C. Logo and layout should use PNG or SVG format

4. Enable Flat Categories and Products

One of the main problems that slow down magento 2 speed is the read speed of database; especially, in case your magento 2 store has a large number of products.
To enable flat-options:
Go to Stores -> “Configuration” in “Settings” Section -> “Catalog” in “General” Tab -> Section “Storefront” -> Fields “Use Flat Catalog Category” and “Use Flat Catalog Product” change to “Yes

Enable Flat Categories and Products


5. Change to production mode:

php bin/magento deploy:mode:set production:

6. Optimize magento database by Cleaning log

If you are wondering when you need to optimize magento database, you can check your site. In case you have around 200MB, it is time for cleaning.

As you can see, database is needed for better tracking in case something wrong happen with your customers and their order. Hence, before you do anything related to database, please backup data first. Here is step by step to clean database log

>> Optimize magento database Log Cleaning
There are three options for you to clean out: via Log Cleaning in the Magento Admin, via log.php in the ../shell directory, and manually via phpMyAdmin or mysql client.

7. Use Built-in Cache, Skip Varnish

Magento 2 has two options for Full Page Cache: built-in application and Varnish. You can choose between the two at Stores > Configuration > Advanced > System ( on M2.2.2 you need to be in developer mode to make a switch ):

My advice – do not use Varnish. I will name you three reasons why you should avoid it:

  1. Additional point of failure
    Varnish is a 3rd-party software that a. Would break b. needs maintenance and upgrades.
  2. Not so easy with SSL traffic
    Secure traffic is a must-have nowadays but you might face serious difficulties trying to setup Varnish over SSL. There are workarounds but they don’t always work.
  3. Random access
    Site visitors access random pages which are not always cached. More on that you can read here.

8. Enable Flat Categories and Products

Stores-> Configuration-> Catalog-> Catalog-> Storefront