The Ultimate Guide to Speeding Up Magento 2
Have you ever clicked on a site only to leave because the pages took forever to load?
According to Google, the bounce rate increases by 32% if a page takes just 3 seconds to load, this underscores the importance of having a fast website to retain customers.
While Magento 2 is powerful, it may not always deliver top speed right out of the box. So, understanding how to tweak and fine-tune your store is crucial for your business success. The main goal is to create a shopping experience that is seamless and enjoyable for your customers.
Why Magento performance optimisation is important
The impact of load speed on user experience and conversions
When it comes to your online store, speed is a critical factor in user experience and sales. Just like slow service or a poor customer experience can drive you away from a physical store, a slow-loading website or a frustrating online experience can turn away customers from an online store.
Here’s the kicker, each extra second of load time cuts conversion rates by 7% – For desktop users, slow websites can lead to a shopping cart abandonment rate of over 70%. The news gets worse for B2C retailers, as 79% of customers are less likely to return to a website if the performance is slow the first time around.
The magic number for making visitors stick around? Aim for a load time of 700ms to 1.2s. That’s the sweet spot.
Speed isn’t just important for your user experience, it also impacts your search engine rankings, so the faster your website, the more customers you’ll be found by, and the more revenue you’ll bring in. It’s a win-win.
In conclusion, slow site speed kills conversion, and ultimately, your bottom line. So keep those load times fast, and your customers will thank you.
Practical tips for optimising Magento 2 – The basics:
Improving hosting and server performance
If a website is slow and unresponsive, that may be due to the hosting service it’s using. Opting for a reliable hosting provider with high-performance capabilities can be the make or break for your customers.
When choosing your server, consider these upgrades:
- Opt for SSD storage over traditional HDDs for faster data access.
- Ensure your server has enough power (like CPU and RAM) to handle spikes in visitor traffic.
Use HTTP/2 to speed up data transfer.
Implement server-level caching solutions, such as Varnish, to enhance performance.
These improvements can make your website more accessible, responsive and enjoyable for your customers.
Remember to keep in mind your Magento system requirements to keep everything running smoothly.
Implementing a Content Delivery Network (CDN)
Imagine if your website could serve content from a location closer to your visitors. This is the function of a Content Delivery Network (CDN). A CDN enhances your website’s speed by storing and delivering content, such as images and scripts, from servers that are geographically closer to your users.
By using a CDN provider like Cloudflare and integrating it into your Magento 2 store, your load time will be dramatically reduced.
Caching techniques for faster page loading
Caching helps to store parts of your site on your customers’ devices, reducing the need for them to reload content every time they visit. In Magento 2, you can enable built-in full-page caching to significantly improve page load speed and enhance overall frontend performance.
Magento 2 offers two caching options: the built-in cache and the Varnish cache. For production environments, Magento recommends using Varnish as the full-page cache due to its superior performance. The built-in cache is best suited for developer mode.
By using full-page caching, you’re essentially storing snapshots of each page. So instead of generating the same page every time someone visits, your site just flips through the pre-downloaded pages.
For the ultimate hack, you can combine the Redis backend cache with the Varnish full-page cache.
If you need any help setting this up, get in touch with our team.
Optimising images for improved speed
Large image files don’t always equal better quality and performance. 9 out of 10 times, they do the exact opposite. For example, if an image is going to display at 1920 x 1080 pixels, you don’t need to export it at 3840 x 2160 pixels. Make sure the images fit their display sizes, and use the right image format and compression:
- WebP is overall the best solution, no matter the size
- JPEG for photos
- PNG for transparent images – but only use PNG where you really need to
Simple.
Remember to optimise images across your site, not just photos, but thumbnails, favicons, and banners too.
It might also be useful to apply a Magento 2 Lazy Loading extension to the site, so it only loads images that are in view, while the others load as the user scrolls.
Managing and optimising third-party extensions
Are your extensions up to date?
If you have to think about it, chances are they need an update.
Keeping your extensions updated is crucial for your site’s performance and security. Developers release updates for a reason—whether to fix slow speeds, resolve bugs, or address glitches. Sometimes, a module may be installed, but no longer in use, causing issues.
Staying current with these updates ensures your site runs smoothly and remains secure. Regular updates help you benefit from the latest improvements and prevent potential issues before they affect your customers.
Fixing URL redirects for better performance
Redirects can slow down your site if not done properly. Here are a few ways you can make sure they’re all good:
- Identify and Eliminate Redirect Chains: Redirect chains occur when there are multiple redirects before reaching the final destination. Use tools like Screaming Frog or Google Search Console to identify all existing redirect chains on your site. Simplify these chains by creating direct paths to the final URL using server-side redirects (like 301 or 302).
- Use Server-Side Redirects: Server-side redirects (301 or 302) are processed faster in browsers, so best to use this. A 301 redirect is permanent and tells search engines to update their index, while a 302 redirect is temporary and does not update the index. Use the appropriate type based on your needs to keep your site running smoothly.
- Optimise Redirect Paths: Make sure there aren’t multiple redirects for a single URL. Each additional redirect adds to the page load time, impacting the user experience. Consolidate and streamline your redirect paths to minimise the number of steps needed to reach the final destination.
- Regularly Check for Broken or Outdated Redirects: Over time, URLs change, and redirects can become outdated or broken. Regularly audit your site to check for these issues. Tools like Ahrefs or SEMrush can help you identify broken or outdated redirects. Fix these promptly to ensure users and search engines can easily navigate your site.
- Update Internal Links: Where possible, update internal links to point directly to the final destination URL rather than relying on redirects. This reduces the number of requests made to the server and speeds up page load times.
- Monitor Performance Impact: Use performance monitoring tools to track the impact of your redirect management efforts. Tools like GTmetrix, Google PageSpeed Insights, or Pingdom can help you measure improvements in load times and overall site performance.
By effectively managing redirects, you can significantly enhance your site’s speed and user experience, keeping your customers engaged and satisfied.
Reducing server requests for faster load times
Every request your server makes slows things down. To reduce these requests, combine your CSS and JavaScript files so there are fewer to load. Enable minification to shrink these files and speed up loading.
You can also remove or delay non-essential third-party scripts, inline important CSS to load faster JavaScript files in the background or after the main content or use techniques like prefetching to also help speed up your site.
Identifying and optimising code
Old or inefficient code can significantly slow down a website. Take a look at these areas:
- Queries: Look at your database queries to ensure they are running as quickly as possible. Look for queries that are slow or inefficient and optimise them by adding indexes where necessary or rewriting them for better performance.
- Duplicated code: Over time, codebases can collect redundant or outdated code. This clutter can slow down your website and make it harder to maintain. Conduct a review of your code to identify and eliminate any duplicate or unnecessary code segments. Refactor your code to ensure that it is clean and concise.
- Profiling: Utilise performance profiling tools to find and address performance issues in your code. Tools like Xdebug for PHP or Blackfire can help you analyse how your code executes and where it might be slowing down. Profiling can show inefficiencies that aren’t obvious during regular testing, allowing you to target specific areas for optimisation.
- Over complication: Complex processes can be a major drain on performance. Review your code to identify any overly complicated logic or processes that could be simplified. Break down complex tasks into smaller, more manageable functions. By streamlining these processes, you reduce the load on your server and make your code more efficient and easier to maintain.
- Structure: Pay attention to how loops and algorithms are structured. Inefficient loops or poorly designed algorithms can significantly impact performance. Optimise your loops to ensure they run in the most efficient manner possible, and consider more efficient algorithms if they apply to your use case.
It’s all about being efficient with your site’s scripts and styles.
Keeping the Magento 2 store updated for improved performance
Apply core updates and security patches regularly to benefit from the latest improvements. You can stay up to date with patches here.
Test updates in a staging environment first to avoid problems on your live site. Back up your store before applying updates and use version control to manage changes effectively.
GZIP compression
GZIP compression enhances your website’s performance by reducing the size of your HTML, CSS, and JavaScript files before they are sent from the server to the browser. Essentially, this lessens the amount of information downloaded, so it makes the site quicker.
Enabling GZIP compression on your Magento 2 store is a fairly straightforward but highly effective way to improve site speed, enhance user satisfaction, and ultimately boost your conversion rates.
However, there’s no one-size-fits-all here, it’s all about finding what works for you and your store, research is key.
Testing and monitoring performance
You can use tools like Google PageSpeed Insights, GTmetrix, and Pingdom to check how well your site loads and find areas to improve.
Real User Monitoring (RUM) helps you see how actual visitors experience your site.
Set up performance monitoring tools like New Relic or Datadog to track your server’s health.
Conduct load tests to see how your site handles high traffic. Regular reviews and adjustments will keep your site running smoothly.
Final thoughts
If you follow this guide, your site should run smoothly, and most importantly, fast. A fast, responsive site not only improves your customer satisfaction but also boosts your revenue. A win-win.
FAQs
How can I determine if my Magento 2 store is slow?
You can use performance testing tools, such as Google PageSpeed Insights, GTmetrix, and Pingdom to measure the loading speed. Anything longer than 3 seconds is considered too long.
In addition to this, listen to customer feedback, and use Google Analytics to analyse further.
What are the most common performance issues in Magento 2?
Common issues include:
- Slow servers
- Unoptimised code
- Heavy database queries
- Large images
- Too many extensions
- Improper caching
You can see how to fix these common Magento 2 issues in the article above.
How often should I test my Magento 2 performance?
This should be a regular part of your processes, conduct monthly tests as a minimum, but also after major updates, before and after promotions and perform a comprehensive and in-depth review quarterly. This will ensure you don’t miss out on any key issues impacting your site performance.
When should I use a Magento professional?
Consider using a Magento performance service in the following situations:
- Persistent Slow Performance: If your site continues to experience slow performance despite implementing basic optimisations, a performance service can provide expert analysis and solutions.
- Complex Performance Issues: For issues that are difficult to diagnose or resolve with standard tools, a performance service can offer specialised expertise.
- High Traffic Periods: If you anticipate a significant increase in traffic (e.g., during major sales or promotions), a performance service can help ensure your site is prepared to handle the load.
- Lack of In-House Expertise: If your team lacks the specialised knowledge required for advanced performance tuning, a professional service can provide the necessary skills and experience.
- Comprehensive Optimisation: When you need a thorough optimisation strategy that includes server configuration, code review, and advanced performance tuning, a performance service can offer a tailored approach.
(This is where we do our shameless self-promotion) If you’re asking the question, you probably already need one. We’re here to help. We can help with all your website development needs, from just some friendly advice to the full build, we’ve got your back. Get in touch with us here.