At Nexcess, we spend a considerable amount of time optimizing our infrastructure to make your Magento 2 store faster. After years of research and development, we’ve pulled together the ultimate Magento 2 checklist for performance.
Keep reading for eight actionable techniques featured in this Magento 2 checklist to optimize your site.
Magento 2 Checklist for Performance
1. Remove Unused Modules
Magento 2 comes with many pre installed modules that aren’t always needed. Yireo created a great module to disable the optional modules you don’t need through composer.
The idea behind the module is quite simple: you replace any unused module with nothing to avoid loading unused modules and classes. This module and a complete how-to can be found here.
2. Enable CSS/JS Minification and Merging
Minifying and merging CSS files can greatly improve load times and the general performance of your store by cutting the number of requests your site makes when loading a page.
You can minify and merge CSS and JS files from the admin panel by navigating to the Developer tab under Stores > Configuration > Advanced (keep in mind this tab will only show if you are using developer mode).
3. Enable Production Mode
While this one might seem simple, the number of sites we see using a different mode in Magento is staggering. No one should be running Magento 2 in production in a different mode, but we still see too many stores running on either default or developer mode.
The best way to switch modes is via CLI:
to see which mode is your store using and
php bin/magento deploy:mode:set production
to set production mode.
4. Use Redis for Session/Default and Full Page Cache
Redis is one of the most used key/value database engines and Magento 2 comes with integrated support to use it as a both session storage and default/full page. To configure your store to use Redis, run the following commands from your root folder:
bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-
bin/magento setup:config:set --session-save=redis --session-save-redis-
5. Use Elasticsearch for Magento’s Catalog Search
Since Magento 2.4, MySql was deprecated (and removed) and Elasticsearch was introduced as the catalog search engine, greatly improving the speed and results of the searches.
To enable Elasticsearch, navigate to your admin panel and under Stores > Settings > Configuration > Catalog > Catalog > Catalog Search where you will find a tab called Search Engine.
Configure your store to use your Elasticsearch endpoint, click Test connection and if everything worked, you’re all set. You can find the complete list of parameters to configure Elasticsearch here.
6. Use Varnish to Speed Up Your Response Time/TTFB
You either love or hate Varnish but at the end of the day, it greatly improves the TTFB, and if configured correctly, it can do wonders for the general usability and user experience of your site. Magento 2 features an out of the box integration, making Varnish configuration really simple.
To configure Varnish, navigate to Stores > Settings > Configuration > Advanced > System > Full Page Cache, select Varnish from the Caching Application list and configure the rest of the options. A full list of all the parameters you can use to configure Varnish can be found here.
You can also configure Varnish from the CLI by running:
php bin/magento config:set --scope=default --scope-code=0 system/full_page_cache/caching_application 2
7. Use a CDN
A content delivery network is normally used to store media and static assets at edge servers near your customers for faster delivery. This means your assets are physically closer to your customer, resulting in faster response times. Configuring a CDN for Magento is not as straightforward as it should be but it can be achieved by using the admin and navigating to Stores > Settings > Configuration.
Do the same for Base URLs (Secure) and once done, click Save config. You might need to flush/clean your cache for this change to take effect. If everything worked as expected, you should be seeing your CDN url being used to serve most of your site’s static files.
8. Enable Asynchronous Email Notifications & Order Data Processing
During times of high concurrency, you might want to move processes that handle checkout, order processing email notifications and stock updates to the background.
To enable async email notifications, go to Stores > Settings > Configuration > Sales > Sales Emails > General Settings > Asynchronous Sending
You can activate Asynchronous order data processing from Stores > Settings > Configuration > Advanced > Developer > Grid Settings > Asynchronous indexing
When enabled, orders will be placed in temporary storage and moved in batch to the Order grid without any collisions.
Now You Know
We hope this Magento 2 checklist helps! While there are no real magic tricks, we tried this guide in our cloudhosts and ended up with an A and a page load under 2 seconds on GTMetrix 🥳
If you’d like assistance enacting the changes featured in this Magento 2 checklist, or are interested in our Managed Magento offering, please reach out to our award-winning support team 24/7/365 at email@example.com.