7 essential ways to improve your Magento 2 site speed [Updated]

7 essential ways to improve your Magento 2 site speed [Updated]

Magento 2

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

1. Magento 2 System Requirements

The server is the core. And in case the one you picked is not functioning smoothly, you won’t have good website speed nevertheless your efforts and all other tips from this or another article.

Before start magento 2 performance optimization we strongly suggest you placing your store on the dedicated server. While choosing the host, run a check on these categories:

  • Use the dedicated server or VPS, do not pick shared hosting option;
  • Check the following System Requirements for Magento 2:

Operating systems: Linux x86-64. Linux distributions such as RedHat Enterprise Linux (RHEL), CentOS, Ubuntu, Debian,etc

Composer: Latest stable version.Composer is required for developers who wish to contribute to the Magento 2 codebase or anyone who wishes to develop Magento extensions.

Web servers: Apache 2.2 or 2.4. In addition, the apache mod_rewrite module must be enabled. mod_rewrite enables the server to perform URL rewriting. For more information, see our Apache documentation. NGINX 1.8 (or latest mainline version).

Composer: Latest stable version.Composer is required for developers who wish to contribute to the Magento 2 codebase or anyone who wishes to develop Magento extensions.

Database: MySQL 5.6 (Oracle or Percona)

PHP: 7.1.3+ or 7.2.x

Required PHP extensions: bc-math curl gd, ImageMagick 6.3.7 (or later) or both intl mbstring mcrypt mhash openssl PDO/MySQL SimpleXML soap xml xsl zip PHP 7 only: json

Database: MySQL 5.6 (Oracle or Percona)

PHP OPcache: PHP OPcache is strongly recommended to be enabled for performance reasons. The OPcache is enabled in many PHP distributions. To verify if it is installed, see our PHP documentation for CentOS or Ubuntu.If you must install it separately, see the PHP OPcache documentation.

PHP settings: Particular PHP configuration settings, such as memory_limit, that can avoid common problems when using Magento are recommended.

SSL: A valid security certificate is required for HTTPS. Self-signed SSL certificates are not supported. PayPal: You must use libcurl version 7.34 or later for Transport Layer Security (TLS) version 1.2 support required by PayPal.

Mail server: Mail Transfer Agent (MTA) or an SMTP server

Magento can utilize the following technologies:: Redis version 3.0 for page caching Varnish version 3.5 or latest stable 4.x version for page caching memcached latest stable version for session storage with either memcache or memcached PHP extensions (latest stable version) Magento Enterprise Edition (EE) only: Apache Solr 4.x RabbitMQ 3.5; Three master databases.

Optional but recommended: MySQL 5.6 (Oracle or Percona)

Database: php_xdebug2.2.0 or later (development environments only; can have an adverse effect on performance); PHPUnit (as a command-line tool) 4.1 or later

2. Enable Flat Categories and Products

One of the top reasons of Magento speed issues with database read speed. To fasten the read speed of the database you should enable Flat Catalog. This will minify the number of database joins done when showing products and due to that the MySQL query complexity will be reduced.

Go to backend, STORES -> Configuration -> CATALOG -> Catalog -> Use Flat Catalog Category and put “Yes

Enabling Flat categories in Magento 2

3. Merge CSS and JS Files

Huge CSS and JS files apart from making your frontend look fancy can drop your website loading speed. Luckily, there is a way to lessen their influence in Magento 2.

  1. Go to backend, STORES -> Configuration -> ADVANCED -> Developer -> JavaScript Settings
  2. Merge JavaScript Files -> Yes
  3. Minify JavaScript Files -> Yes

Merge and Minify Javascript in Magento 2

  1. Go to backend, STORES -> Configuration -> ADVANCED -> Developer -> CSS Settings
  2. Merge CSS Files -> Yes
  3. Minify CSS Files -> Yes

Merge and Minify css in Magento 2

Don’t forget to press Save Config after you are done!

4. Content Delivery Network

CDN, or Content Delivery Network, is an interconnected system of cache servers that use geographical proximity as criteria for delivering web content and actually helps your visitors to load pages faster as a result.

There are many types of CDNs, just look through features provided, geo coverage and choose the one you like.

One of the Magento 2 features is out-of-the-box support of CDN and here’s where you may find set up for it: STORES -> GENERAL -> Configuration -> Web -> Base URLs (Secure)

Enable CDN in Magento 2

5. Caching

Magento 2 has a variety of caching options, here’s where you can find them: SYSTEM -> Cache Management

Cache settings Magento 2

Here you will find caching options of your Magento store, click on the ones you need, select Enable option and click Submit Page Cache can significantly reduce server response time and total page load time as result.

But M2 create cache instance for each page (categories, products etc) only after visiting this page and usually cache lifetime less one day.

Magento 2 module Page Cache Warmer can automatically visits pages without cache and warms cache for these pages.

Magento 2 Full Page Cache

6. Images Optimization

Before any image upload, make sure it’s compressed – there is no need for huge images beyond your layout capabilities. Also, pick the format that suits the most your needs. For ecommerce, with a tremendous amount of product images, it is even more crucial not to overload site. The suggestion we have for you: use JPEG format for Product images. It is way more suitable for pictures than other formats as you can compromise quality for less size. On the other hand, using PNG or SVG for layout and logo is way more beneficial. So use accordingly!

7. Magento Updates

Tiny simple tip: do not forget to update your store. Magento team is constantly working hard on improvements of performance, so don’t miss out any!

Summary

Let’s sum up the key points:

  1. Don’t forget to enable flat products and categories to ease the MySQL queries.
  2. Merge CSS and JS files to make user experience enjoyable.
  3. Implement CDN for your store – Magento 2 supports it out-from-the-box.
  4. Have caching enabled.
  5. Do not overload your website with high-quality images where it is not necessary.
  6. Don’t forget about your CMS updates.