Configure Magento with LiteSpeed Cache for Speed
LiteSpeed Cache is one of the most effective ways to speed up your Magento store. This guide explains how to install and configure the LiteSpeed Cache extension for Magento 2.
What is LiteSpeed Cache?
LiteSpeed Cache (LSCache) is a server-level caching solution that:
- Caches entire pages at the server level
- Significantly reduces page load times
- Works seamlessly with LiteSpeed Web Server
- Is free to use with LiteSpeed hosting
Benefits Over Other Cache Solutions
| Feature | LiteSpeed Cache | Varnish | Built-in FPC |
|---|---|---|---|
| Server-level | Yes | Yes | No |
| ESI Support | Yes | Yes | Limited |
| Easy Setup | Yes | Complex | Yes |
| CDN Integration | Built-in | Requires config | No |
| Image Optimization | Yes | No | No |
Prerequisites
Before installing LiteSpeed Cache:
- LiteSpeed Web Server - Your hosting must use LiteSpeed (not Apache/Nginx)
- PHP 7.4+ - Recent PHP version
- Magento 2.3+ - Compatible Magento version
Check if you have LiteSpeed:
- Look for LiteSpeed in your hosting control panel
- Or check server headers
Installation
Via Composer (Recommended)
composer require litespeed/module-litemage
php bin/magento module:enable Litespeed_Litemage
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:clean
Via Magento Marketplace
- Purchase (free) from Adobe Marketplace
- Add to your project via Web Setup Wizard
- Run setup commands
Configuration
Enable LiteSpeed Cache
- Go to Stores > Configuration > LiteMage Cache
- Set Enable LiteMage Cache to Yes
- Click Save Config
Basic Settings
General Settings:
- Enable LiteMage Cache: Yes
- Default Cache TTL: 86400 (24 hours)
- Home Page TTL: 86400
- Category Pages TTL: 86400
- Product Pages TTL: 86400
Cache Warming
Automatically cache pages after purge:
- Enable Cache Crawler
- Set crawl frequency
- Configure sitemap URL
ESI (Edge Side Includes)
ESI allows caching of page parts separately:
Recommended ESI Blocks:
- Mini cart
- Customer greeting
- Compare products
- Recently viewed
Configure in: Stores > Configuration > LiteMage Cache > ESI Settings
Advanced Configuration
Vary by Cookie
Cache different versions based on:
- Currency
- Customer group
- Store view
Cache Exclusions
Do not cache:
- Checkout pages (automatic)
- Customer account pages (automatic)
- Pages with dynamic content
Add exclusions: LiteMage Cache > Do Not Cache URLs
Private Cache
For logged-in customers:
- Enable private cache for personalized content
- Set appropriate TTL
- Configure ESI for dynamic blocks
Image Optimization
LiteMage includes image optimization:
-
Enable WebP:
- Stores > Configuration > LiteMage Cache > Image Optimization
- Enable WebP Replacement: Yes
-
Lazy Loading:
- Enable Lazy Load Images: Yes
- Improves initial page load
-
Responsive Images:
- Enable responsive placeholders
- Reduces bandwidth usage
CDN Configuration
LiteSpeed integrates with CDN:
-
QUIC.cloud (LiteSpeed CDN):
- Free tier available
- Easy integration
- Global distribution
-
Third-party CDN:
- Configure CDN URL
- Set up proper headers
Testing Your Cache
Check Cache Status
- View page source or headers
- Look for X-LiteSpeed-Cache: hit
- First visit: miss, subsequent: hit
Debug Mode
Enable for troubleshooting:
- Stores > Configuration > LiteMage Cache
- Enable Debug: Yes
- Check var/log/litemage.log
Performance Testing
Before and after comparison:
- Google PageSpeed Insights
- GTmetrix
- WebPageTest
Cache Purging
Manual Purge
Admin Panel:
- System > Cache Management
- Click Flush LiteSpeed Cache
Command Line:
php bin/magento cache:clean
Automatic Purge
LiteMage automatically purges:
- Product pages on product update
- Category pages on category update
- CMS pages on content update
Purge by Tag
Selective purging by:
- Product ID
- Category ID
- CMS page
Troubleshooting
Cache Not Working
- Verify LiteSpeed server is running
- Check .htaccess for LiteSpeed rules
- Review error logs
- Test with simple HTML page
Stale Content
- Check TTL settings
- Verify automatic purge is working
- Test manual purge
ESI Issues
- Verify block configuration
- Check ESI hole punch markers
- Review debug logs
Best Practices
Optimal TTL Values
| Page Type | Recommended TTL |
|---|---|
| Home page | 1-24 hours |
| Category pages | 4-24 hours |
| Product pages | 1-6 hours |
| CMS pages | 24+ hours |
Do Not Cache
- Pages with real-time inventory
- Personalized recommendations
- Dynamic pricing pages
Monitor Performance
- Set up uptime monitoring
- Track cache hit ratio
- Monitor server resources
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