A fast Magento webshop is essential for a good user experience and higher conversions. In this guide, we explain how to optimize your Magento installation for maximum performance.

Why Speed Matters

  • Better user experience: Visitors leave slow websites
  • Higher conversions: Faster pages mean more sales
  • Better SEO: Google rewards fast websites
  • Lower server load: Efficient caching reduces resource usage

Built-in Magento Cache

Cache Types

Magento has several cache types:

Cache Type Description
Configuration System configuration
Layouts Page layouts
Blocks HTML output HTML blocks
Collections Data Database collections
Reflection Data API interfaces
Database DDL Database schema
EAV types and attributes Entity attributes
Full Page Cache Complete pages
Translations Language files

Enable All Cache

  1. Go to System > Cache Management
  2. Select all cache types
  3. Choose Enable from the dropdown
  4. Click Submit

Flush Cache

After making changes:

  1. Go to System > Cache Management
  2. Click Flush Magento Cache
  3. For more thorough cleaning: Flush Cache Storage

Manage Cache via SSH

The command line is faster. Run these commands in the Magento directory:

# show the status of all cache types
bin/magento cache:status

# enable all cache types
bin/magento cache:enable

# clean specific cache types only
bin/magento cache:clean config layout

# flush all cache
bin/magento cache:flush

Full Page Cache (FPC)

Full Page Cache is the most important for performance.

Built-in FPC

  1. Go to Stores > Configuration > Advanced > System
  2. Under Full Page Cache:
    • Caching Application: Built-in Cache
    • TTL for public content: 86400

Varnish is faster than built-in cache:

  1. Install Varnish on your server
  2. In Magento: Stores > Configuration > Advanced > System
  3. Caching Application: Varnish Cache
  4. Export VCL configuration
  5. Configure Varnish with exported VCL

Redis for Session and Cache

Why Redis?

  • Faster than file-based storage
  • Better for multi-server setups
  • Reduces disk I/O

Configure Redis for Cache

In your app/etc/env.php:

'cache' => [
    'frontend' => [
        'default' => [
            'backend' => 'Magento\\Framework\\Cache\\Backend\\Redis',
            'backend_options' => [
                'server' => '127.0.0.1',
                'port' => '6379',
                'database' => '0'
            ]
        ]
    ]
]

Configure Redis for Sessions

'session' => [
    'save' => 'redis',
    'redis' => [
        'host' => '127.0.0.1',
        'port' => '6379',
        'database' => '1'
    ]
]

Index Optimization

Indexer Modes

  • Update on Save: Real-time, but slower
  • Update by Schedule: Faster, uses cron

Set Schedule Mode

  1. Go to System > Index Management
  2. Select all indexers
  3. Choose Update by Schedule
  4. Click Submit

Or via SSH:

bin/magento indexer:set-mode schedule
bin/magento indexer:status

Manual Reindex

Via command line:

bin/magento indexer:reindex

Production Mode

Run Magento in production mode for the best performance:

bin/magento deploy:mode:set production
bin/magento deploy:mode:show

In production mode, static files are generated in advance and visitors do not see error messages (they only go to the logs). After changes to your theme or extensions, deploy the static content again:

bin/magento setup:static-content:deploy en_US

After installing or updating extensions, run bin/magento setup:di:compile first. In developer or default mode, add -f to force the deployment.

Image Optimization

Enable Lazy Loading

Images only load when visible on screen, improving initial page load.

Resize Images

  1. Go to Stores > Configuration > Advanced > System
  2. Under Image Optimization
  3. Enable image resizing

Use WebP Format

WebP images are smaller than JPEG/PNG:

  1. Install a WebP module
  2. Configure automatic conversion
  3. Serve WebP to supported browsers

JavaScript and CSS Optimization

Merge and Bundle

  1. Go to Stores > Configuration > Advanced > Developer

  2. Under JavaScript Settings:

    • Merge JavaScript Files: Yes
    • Enable JavaScript Bundling: Yes (test thoroughly)
    • Minify JavaScript Files: Yes
  3. Under CSS Settings:

    • Merge CSS Files: Yes
    • Minify CSS Files: Yes
  • Move JavaScript to bottom of page
  • Improves perceived loading speed

Database Optimization

Regular Maintenance

Clean up old data:

  • Old quotes (abandoned carts)
  • Log tables
  • Old sessions

Query Optimization

  1. Find slow queries via the MySQL slow query log (the query cache no longer exists in MySQL 8.0)
  2. Optimize slow queries
  3. Add indexes where needed

CDN Integration

Benefits of CDN

  • Faster static file delivery
  • Reduced server load
  • Global distribution

Configure CDN

  1. Go to Stores > Configuration > General > Web
  2. Under Base URLs for Static View Files
  3. Enter your CDN URL

Monitoring Performance

Tools

  • Google PageSpeed Insights: Free analysis
  • GTmetrix: Detailed performance report
  • New Relic: Server-side monitoring

Key Metrics

  • Time to First Byte (TTFB)
  • Largest Contentful Paint (LCP)
  • Total Blocking Time (TBT)

Performance Checklist

  • Production mode enabled
  • Full Page Cache active
  • Static content deployed
  • Indexers in schedule mode
  • Magento cron runs every minute
  • LiteSpeed Cache configured
  • PHP OPcache enabled

Need Help?

We are here for you! If you run into any issues or have questions, our support team is happy to help you personally. Send us a message through the ticket system - we usually respond within a few hours and are happy to assist you.

Looking for web hosting? See what we offer.