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

Magento 2 speed optimization is quite an important step in your plan to bring high traffic to your store.

1. Magento 2 System Requirements

The server is the core. If the server you selected is not functioning smoothly, you won’t have good website speed regardless of the effort you put in, or any other tips from this or another article.

Before starting Magento 2 performance optimization we strongly suggest you place your store on the dedicated server. While selecting a host, run a check on the following categories:

  • Use the dedicated server or VPS, do not pick the 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: Enabling PHP OPcache is strongly recommended 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 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 the latest stable 4.x version for page caching Memcached, the 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. (not sure where the deliniation between the different listed technologies are in terms of commas and separating words)

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 for Magento's speed issues with database is read speed. To quicken the read speed of the database, you need to enable Flat Catalog. This will minify the number of database joins done when showing products, on account of which, 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

Apart from making your frontend look fancy, huge CSS and JS files 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 load pages faster as a result.

There are many types of CDNs, just look through the features provided, get coverage and choose the one you like.(it's supposed to be 'get coverage,' not 'geo coverage,' right?)

One of the Magento 2 features is out-of-the-box support of CDN; here’s where you can find the 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 to significantly reduce server response time and total page load time as a result.

But M2 creates cache instances for each page (categories, products, etc) only after visiting this particular page, and usually a cache lifetime is less than one day.

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

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 most of 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 or this approach

It is way more suitable for pictures than other formats as you can compromise the quality for a smaller size. On the other hand, it is much more beneficial to use PNG or SVG for layout and logos.

So use accordingly!

7. Magento Updates

Here's a quick and simple tip: do not forget to update your store. Magento team is constantly working hard on improvements in performance, so don’t miss out on 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 the user experience enjoyable.
  3. Implement CDN for your store – Magento 2 supports it out-of-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.
Oleksandr Drok

Head of Products at Mirasvit

Alex serves as the Head of Products at Mirasvit, where he formulates the vision for Mirasvit's extensions, carefully curates new features, and constructs the roadmap.

Keep Learning

Loading...