Speed Up Magento: Caching and Performance Optimization
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
- Go to System > Cache Management
- Select all cache types
- Choose Enable from the dropdown
- Click Submit
Flush Cache
After making changes:
- Go to System > Cache Management
- Click Flush Magento Cache
- For more thorough cleaning: Flush Cache Storage
Full Page Cache (FPC)
Full Page Cache is the most important for performance.
Built-in FPC
- Go to Stores > Configuration > Advanced > System
- Under Full Page Cache:
- Caching Application: Built-in Cache
- TTL for public content: 86400
Varnish (Recommended for Production)
Varnish is faster than built-in cache:
- Install Varnish on your server
- In Magento: Stores > Configuration > Advanced > System
- Caching Application: Varnish Cache
- Export VCL configuration
- 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
- Go to System > Index Management
- Select all indexers
- Choose Update by Schedule
- Click Submit
Manual Reindex
Via command line:
php bin/magento indexer:reindex
Image Optimization
Enable Lazy Loading
Images only load when visible on screen, improving initial page load.
Resize Images
- Go to Stores > Configuration > Advanced > System
- Under Image Optimization
- Enable image resizing
Use WebP Format
WebP images are smaller than JPEG/PNG:
- Install a WebP module
- Configure automatic conversion
- Serve WebP to supported browsers
JavaScript and CSS Optimization
Merge and Bundle
-
Go to Stores > Configuration > Advanced > Developer
-
Under JavaScript Settings:
- Merge JavaScript Files: Yes
- Enable JavaScript Bundling: Yes (test thoroughly)
- Minify JavaScript Files: Yes
-
Under CSS Settings:
- Merge CSS Files: Yes
- Minify CSS Files: Yes
Move JS to Footer
- 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
- Enable MySQL query cache
- Optimize slow queries
- Add indexes where needed
CDN Integration
Benefits of CDN
- Faster static file delivery
- Reduced server load
- Global distribution
Configure CDN
- Go to Stores > Configuration > General > Web
- Under Base URLs for Static View Files
- 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)
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.
0 van 0 vonden dit nuttig