In the field of eCommerce website development, Magento occupies a key place among its competitors. Now the share of online stores developed on this CMS is about 11% (or more than 250,000). And there is no surprise to its consistent popularity as it allows retailers to grow three times faster.
Ease of use, customization, and scalability together contribute to its success, along with over 150,000 trained developers worldwide. These experts are constantly working on new extensions so you can add new features to your store and keep your transactions safe.
However, it’s not an easy platform to use, and it requires extensive technical knowledge. Developers have to understand not only the intricacies of the installation but also Magento page speed optimization principles. This article will outline what to do to improve Magento speed.
Magento Performance Tips
Do you know why a slow Magento shop is a terrible thing? The answer is because users won’t waste their time. Their dissatisfaction results in fewer sales and negative experiences. But that’s not all.
Google discriminates against slow websites, too. If your store takes a long time to load, Google will notice and place you lower in the search results than your competitors. With these tips, we will help you make your Magento store fast and snappy to use.Optimize Your Theme & Media Content
1. Optimize Your Theme & Media Content
A heavy Magento theme will make load times longer, even for users with a decent Internet connection. Another side effect of an unoptimized theme is that it uses a lot of bandwidth. So what happens if you have a metered hosting data plan? You are paying for that.
What are the two ways to deal with a bad theme? Let’s start with the most obvious one. It means changing it to something lighter, especially if your theme is old and the developers discontinued its updates.
But let’s say you really like your theme and aren’t in a hurry to change it just to speed up Magento. Your next best option is to make it lighter yourself. How? You can optimize image sizes.
Media content is a huge part of every eCommerce website, it’s essential for selling products. As a result, tackling these files first will yield immediate results, but you’ll have to be thorough in your approach. Images and infographics can take up over half of all content on a web page. To make Magento images load faster, optimize your files using various photo editors or Magento automation extensions. Such solutions include:
- Compression of images before uploading them to the resource (for example, Compress JPEG, TinyJPG, Kraken.io, or more functional JS & CSS Compressor + Image Optimization);
- Cloudflare CDN will help you a lot: you can reach faster content delivery using CDN (Content Delivery Network) or AWS (Amazon CloudFront);
- Using a size that is appropriate for the situation (for example, if an extension of 200*200 is enough for some area, there is no point in uploading larger images).
There are numerous other ways you can optimize images in your Magento store that the Adobe developers explain.
2. Bad Hosting as a Reason for Poor Magento Performance
Do you want to know whether your hosting is slowing you down? It does. If you use a cheap shared web hosting service, you should know that your website can work faster.
Bad hosting can crash your Magento online store. If your site is slow or unavailable, it will increase the bounce as well as the cart abandonment rate. Your sales will drop as no one wants to face delays in page loading. If this happens to your store, it’s time to move to a more productive hosting.
Hosting also affects SEO. Popular and time-tested hosting providers deal with only high-quality sites. Therefore, if you are one of their clients, it will increase your chances of being at the top of the SERP. On the other hand, bad reputable hosting providers handle fraudulent resources. It can threaten the performance and security of other sites that also belong to them.
So, what can you do for Magento 2 speed optimization purposes? Get better bandwidth and hardware to offer your consumers and enhance Magento server response time. There is no way around it. Sometimes paying more is the only option for Magento server optimization.
When you are looking for a hardware upgrade, pay special attention to CPU, RAM, and SSD availability. The more RAM and CPU you get, the better. We recommend 4 GB of RAM as the bare minimum and will work for sites with up to several hundreds of visitors and a couple of dozens of orders per day.
On the software side, look for HTTP/2 (and soon HTTP/3) support, Nginx 1.x, Apache 2.2+, MySQL 5.7, PHP 7.1.x+, PHP OPcache, Varnish, Redis or Memcached (Redis is preferred), PHPUnit.
Look out the most recent Magento system requirements and make sure your hosting provider complies with them as well to make your Magento future-proof.
Address your hosting provider if they have a better plan for Magento storefronts. Upgrade to more powerful hardware and feel the difference. As a bonus, you get better SEO rankings (Google loves fast websites) and more sales from the improved user experience.
To solve this problem, you can use VPS/VDS like:
- Liquid Web;
Keep in mind that higher powerful virtual/dedicated servers are more expensive. Shop around until you find a price-to-performance ratio that you like.
3. Replace Apache with Nginx
After we went through various hostings, it is high time to focus on the other important point: choosing the right web server that meets the Magento 2 system requirements.
The truth is that performance issues might sometimes be caused by the web server. When there are too many requests, the web server needs more time to process them. It may be the reason for significant downtime.
To make your Magento website load faster, you need to hunt up a web server that will be able to process the request quickly and efficiently deliver both PHP and static content.
As we’ve seen, Magento works best with Nginx and Apache. So, which is the better option for Magento performance tuning?
We’ll start by saying that Magento itself recommends using Nginx rather than Apache, as the first one contains settings for increasing website performance.
Moreover, many web hosts consider Nginx to be an optimal solution to serve both static and dynamic content while handling an enormous number of requests. This approach uses fewer resources to cope with more significant loads and responds with blazing speed.
4. Excessive Number of Unnecessary Extensions
The performance of all web solutions depends on the number of extensions and modules, regardless of the platform. For example, the page will load slower if many HTTP requests are coming into the system.
Too many extensions can affect Magento speed through a variety of means:
- Custom extensions can overload the server due to some critical issues overlooked by developers.
- Installing a great number of extensions that actually provide similar features overloads the system and makes Magento site loading slow down. As a result, these extensions perform the same operations, request the same data, and process it many times. Needless to say that these repeated actions affect speed negatively.
- Installing third-party extensions with many features, most of which are never used. The unused features create an unobvious load on the system’s performance.
- When it comes to third-party extensions, the only way to avoid the problems with them is to constantly review your website with Magento Profiler to check for possible performance killers.
That said, one of the hacks on how to speed up Magento’s page load time is making sure you know what all extensions do on your website. Are they all necessary? Every time you install something new, Magento suffers a minor performance hit.
Check what plugins are installed on your platform. There may be something outdated or unnecessary that you can disable. Or you may need to remove the module files, which is a further step. Also, if the module works with a database, you will have to delete its data.
To shed the dead weight, take a look at your Modules folder located at /app/etc/modules. Do you recognize everything you see there? Turn off or completely remove unnecessary extensions from your store to make your Magento website faster.
Overriding plugins works in a similar manner. You’ll need to audit your Magento install to see which plugins are needed and which you can safely override or turn off.
When it comes to extension use, the general rule is to use preferences if you need to alter Magento core functionality. The second best option is plugins.
5. You Haven’t Enabled Caching
The turned-off caching will slow down the load time of your store. To prevent the page from loading every time, like it’s the first time, use the standard page caching tool for Magento 2 or Varnish. Here’s how you can install and configure the latter.
Adobe developers recommend the second variant more. Thanks to caching, the request is returned instantly. Since the system previously saved it, it won’t be processed in the back-end.
Caching allows you to significantly (from 300 to 1000 times) speed up the loading of static page elements. Also, users will be less dependent on the Internet connection as they will view the previously loaded pages. As a result, you will get lightning-fast page loading and increased sales.
Use Memcached or Redis for Magento 2
Memcached is interchangeable with Redis, but you should use either Memcached or Redis and not both. Although Memcached is a less desirable option than Redis, we want to provide you with both options in case you need to utilize Memcached for whatever reason.
How to Setup Redis for Magento 2 Performance Enhancement
Most hosting providers can help you install Redis. After the installation, you’ll need to configure it, too. Default configuration settings for the server are fine most of the time. However, we’d advise reading the setup manual for a more in-depth look at Magento server optimization.
There are very detailed, step-by-step installation instructions. You’ll find source files alongside the setup guides for the most popular operating systems: Ubuntu 16 and 18, CentOS 7, and Debian 9. That is if you want to do it all yourself, such as install and configure everything.
But you can also install Redis in two commands:
sudo apt-get update sudo apt-get install redis-server
You’ll need to manually navigate to env.php located in the /app/etc/ folder and edit it with any text editor. We used Notepad++ to show you how it’s done.
Initially, the default env.php version will state that it either saves to files (for a local Magento install) or a database (for a live website). Our goal is to save to Redis. To accomplish this, we’ll add the following lines to env.php:
'cache' => array( 'frontend' => array( 'default' => array( 'backend' => 'Cm_Cache_Backend_Redis', 'backend_options' => array( 'server' => '127.0.0.1', 'database' => '0', 'port' => '6379' ), ), 'page_cache' => array( 'backend' => 'Cm_Cache_Backend_Redis', 'backend_options' => array( 'server' => '127.0.0.1', 'port' => '6379', 'database' => '1', 'compress_data' => '0' ) ) ) ),
How do you set up and configure the Redis session cache? You’ll need to install and activate Redis in env.php for session caching in Magento 2.x by default:
Add the following to the code
'session' => array ( 'save' => 'redis', 'redis' => array ( 'host' => '127.0.0.1', 'port' => '6379', 'password' => '', 'timeout' => '2.5', 'persistent_identifier' => '', 'database' => '2', 'compression_threshold' => '2048', 'compression_library' => 'gzip', 'log_level' => '1', 'max_concurrency' => '6', 'break_after_frontend' => '5', 'break_after_adminhtml' => '30', 'first_lifetime' => '600', 'bot_first_lifetime' => '60', 'bot_lifetime' => '7200', 'disable_locking' => '0', 'min_lifetime' => '60', 'max_lifetime' => '2592000' ) ),
You’ll notice the code is not complete. You’ll need to find Redis IP and port settings to make it work for your specific setup. Our input can serve as an example.
6. Start Render Time Optimization
What else can you do to improve the performance of a Magento store? Enhance SRT (start render time).
In essence, the Start Render Time value marks how quickly the site visitor sees requested content on a page. If you keep SRT as low as about 1 second, that’s considered good.
SRT is made up of the TTFB (time to first byte), how long page HTML download takes, parsing the page and downloading resources like CSS, as well as calculating the initial layout.
7. Check the Operational Mode
Finally, Magento can be in one of three modes: Default, Developer, or Production:
- If you use Default mode, you can deploy Magento without changing any settings.
- Developer mode enables enhanced debugging, deep customization, and analysis of Magento.
- Production mode provides a pleasing user experience and is suitable for shoppers.
After working with the store, installing it, or editing it, the staff often forgets to switch the mode. To ensure the proper level of performance, the Magento store must be in Production mode.
High page loading speed is an essential factor that algorithms take into account when ranking. It also reduces user frustration and increases conversions. Optimize your Magento store using our tips to gain more customers and retain the existing ones.