Do you want to make Magento hosting 2 faster? A slow web shop costs you customers and revenue. In this extensive guide we share proven optimization techniques that drastically reduce the loading time of your Magento 2 web shop.

Magento 2 is a powerful e-commerce platform, but speed is not its strongest point. Without optimization, many Magento web shops load in 4 to 8 seconds, while Google recommends staying under 2.5 seconds. In this guide we show you step by step how to make Magento 2 faster.

Why is Magento 2 slow?

Magento 2 is slow because it is a complex platform that does a lot of work on every page load. It loads hundreds of PHP files, runs dozens of database queries, calculates price rules and generates the full HTML page dynamically. Without caching and optimization, that is a heavy job for any server.

The main causes of a slow Magento web shop:

  • Insufficient server memory (less than 2 GB RAM)
  • No full page caching enabled
  • Too many or poorly coded extensions
  • Unoptimized product images
  • An outdated PHP version
  • Slow database queries due to missing indexes
  • No CDN for static files

Step 1: choose the right hosting

Hosting is the foundation of your performance. If your server has too little memory or processing power, no amount of optimization will help. For Magento 2 we recommend at least a VPS with these specifications:

  • CPU: at least 2 cores, preferably 4
  • RAM: at least 4 GB, preferably 8 GB
  • Storage: NVMe SSD for maximum I/O speed
  • Web server: Nginx or LiteSpeed (not Apache)
  • PHP: version 8.2 with OPcache enabled

At Theory7 our VPS plans run on NVMe storage with a LiteSpeed web server. View our web shop hosting for the available options.

Step 2: enable full page caching

Full page caching is the biggest performance gain you can achieve. Instead of generating every page again, the full HTML page is stored and served directly on the next visit.

Built-in full page cache

Magento 2 has a built-in full page cache. Enable it through Stores > Configuration > Advanced > System > Full Page Cache. Set the cache to Built-in Cache if you do not use Varnish. This alone can reduce your loading time by 50 to 70 percent.

Varnish Cache for production

Varnish is a dedicated HTTP cache that sits in front of your web server. It is faster than the built-in cache and can handle thousands of simultaneous visitors. Magento 2 automatically generates a Varnish configuration file that you can use right away. Select Varnish Cache in the full page cache settings and fill in the backend host and port.

Step 3: configure Redis for cache and sessions

Redis is an in-memory database that is much faster than file-based caching. Use Redis for two purposes:

  • Cache backend: speeds up retrieving configuration, layout and block data. Magento no longer has to look for files on disk.
  • Session storage: sessions are stored in memory instead of on disk or in the database. This makes every page load faster.

Configure Redis in the file app/etc/env.php by changing the cache and session sections to the Redis driver. Most Magento hosting providers support Redis as standard on their VPS plans.

Step 4: optimize product images

Product images are often the heaviest elements on a page. A single unoptimized photo can be larger than all the HTML, CSS and JavaScript combined. Optimize as follows:

  • Compress images before upload: use tools such as TinyPNG or ImageOptim. A product photo does not need to be 5 MB; 100 to 300 KB is enough for most shops.
  • Use the WebP format where possible. WebP is 25 to 35 percent smaller than JPEG at comparable quality. Magento extensions such as WebP Converter can automate this.
  • Enable lazy loading so that images only load when they come into the visible part of the page. This speeds up the initial loading time of every category and product page.
  • Set the correct dimensions: do not upload a 4000x4000 pixel photo if it is displayed at 400x400 on your website.

Step 5: minify CSS and JavaScript files

By default, Magento 2 loads many CSS and JavaScript files. Reduce the number of HTTP requests and the total file size with these settings:

  • CSS and JS merging: go to Stores > Configuration > Advanced > Developer > CSS/JavaScript Settings. Enable Merge and Minify for both CSS and JavaScript.
  • JavaScript to the footer: enable the option Move JS code to the bottom of the page. This makes the visible content load sooner and the page feel faster to visitors.
  • Remove unused modules: disable Magento modules you do not use. Every module adds files that have to be loaded.

Step 6: database optimization and indexing

Over time the Magento database grows and queries become slower. Maintain it regularly:

  • Keep indexes up to date: run bin/magento indexer:reindex regularly or set indexing to Update by Schedule.
  • Remove expired sessions and quotes: old shopping cart sessions and expired quotes take up unnecessary space.
  • Enable flat catalog if you have more than 1,000 products. This creates optimized database tables for faster product lists.
  • Optimize tables periodically: run OPTIMIZE TABLE on the largest tables to clean up fragmented data.

Step 7: use a CDN for static files

A Content Delivery Network serves static files such as images, CSS and JavaScript from servers close to your visitors. This lowers the loading time, especially for visitors far from your server. Popular CDN options for Magento are Cloudflare (a free basic plan is available), KeyCDN and Fastly.

Configure your CDN through Stores > Configuration > General > Web > Base URLs (Secure) and fill in the CDN URL for static files and media.

Step 8: enable production mode

Magento 2 has three modes: default, developer and production. Always make sure your live web shop runs in production mode. In production mode, static files are generated in advance, error messages are not shown to visitors and overall performance is significantly better than in developer mode.

Step 9: limit the number of extensions

Every extension adds PHP code that runs on every page load. The more extensions, the slower your web shop. Remove extensions you do not actively use and choose quality extensions from reputable developers. Check the impact of extensions by temporarily disabling them and comparing the loading time.

Measuring and adjusting the result

Measure your loading time before and after every optimization step. Use these tools to monitor your progress:

  • Google PageSpeed Insights: gives a score and concrete points for improvement
  • GTmetrix: detailed waterfall analysis of all requests
  • Magento Profiler: built-in profiling for server-side PHP performance
  • Browser DevTools: the Network tab shows exactly which files load slowly

A well-optimized Magento 2 web shop loads in 1 to 3 seconds. With the steps in this guide and good hosting, that should be achievable for any web shop.

Advanced optimization: Elasticsearch and search performance

Magento 2.4 and higher requires Elasticsearch or OpenSearch for the catalog search function. A poorly configured search engine can slow down your entire web shop, especially if you have many products. Optimize Elasticsearch by assigning enough memory (at least a 512 MB heap size), optimizing the index regularly and removing unnecessary fields from the search index.

Also consider disabling product attributes that do not need to be searchable in the search configuration. The less data Elasticsearch has to search through, the faster the results are shown to your visitors.

Enabling HTTP/2 and HTTP/3

Modern web protocols such as HTTP/2 and HTTP/3 load pages significantly faster than the older HTTP/1.1. HTTP/2 supports multiplexing, which loads multiple files at the same time over the same connection. HTTP/3 goes a step further with the QUIC protocol, which builds connections faster. Check whether your web server supports these protocols and enable them. With Nginx and LiteSpeed, HTTP/2 is available as standard.

Optimizing cron jobs for Magento 2

Magento 2 uses cron jobs for tasks such as indexing, sending email, cleaning up expired sessions and applying catalog rules. Poorly configured cron jobs can put a load on your server and slow down your web shop. Make sure cron runs every minute as Magento recommends, but also check that cron jobs do not overlap or get stuck. Use the command bin/magento cron:run and monitor the cron_schedule table in your database for errors.

Making Magento 2 faster with OPcache

PHP OPcache stores compiled PHP files in memory, so they do not have to be compiled again on every request. For Magento 2, OPcache is essential. Configure at least 256 MB of memory for OPcache and set the maximum number of cached files to at least 100,000. Magento 2 loads hundreds of PHP files on every request, so a well-configured OPcache makes a noticeable difference in the loading time of your web shop.

Making Magento 2 faster: summary and priorities

If you have gone through all the steps in this guide, your Magento 2 web shop should load noticeably faster. You achieve the biggest impact with three measures: powerful hosting with enough memory, full page caching via Varnish or the built-in cache, and optimized product images. These three steps alone can halve your loading time.

After that, Redis for session storage, OPcache configuration and limiting extensions are the next priorities. Database optimization and a CDN deliver the final few percent of improvement. Reaching the goal of making Magento 2 faster is an ongoing process: measure regularly, optimize where needed and keep your software up to date. With the right hosting and configuration, a Magento web shop does not have to be slow.

Do you want to make Magento 2 faster but you do not know where to start? Begin by measuring your current loading time, then implement full page caching and Redis, and optimize your images. These three steps alone already make your web shop noticeably faster. The remaining optimizations are the icing on the cake that help you lower the loading time further, to under two seconds. It is an investment that pays for itself right away in better conversions and satisfied customers.

Frequently asked questions about making Magento 2 faster

How much faster will my web shop be after optimization?

With the steps from this guide you can reduce the loading time of your Magento 2 web shop by 50 to 70 percent. A web shop that now loads in 4 seconds can come in under 2 seconds after applying caching, Redis and image optimization.

Can I make Magento 2 faster without technical knowledge?

You can carry out the basic steps such as compressing images and enabling caching yourself through the Magento admin panel. Advanced optimizations such as Varnish configuration and server-level tuning require technical knowledge. In that case, choose a hosting provider that handles these optimizations for you.

What hosting do I need to make Magento 2 faster?

For optimal speed you need at least a VPS or dedicated server with SSD storage, at least 4 GB RAM and PHP 8.1 or higher. Shared hosting is almost always too limited for Magento 2. At Theory7 we offer optimized Magento hosting with Varnish, Redis and OPcache configured as standard.

Sources and references

  • Google PageSpeed Insights (pagespeed.web.dev)
  • Cloudflare - Learning Center (cloudflare.com/learning)
  • GTmetrix - Website Performance Testing (gtmetrix.com)