Performance and monitoring
LiteMage Cache in Magento 2: install and configure
LiteMage is the LiteSpeed module that replaces Magento 2's full page cache with the cache built into the LiteSpeed web server. Category and product pages are served directly by the server, and personal blocks (cart, customer) are loaded separately with ESI.
The module is free and our servers include LiteMage in their LiteSpeed licence, so you can install it straight away.
Before you start
- Make a backup of your files and database:
setup:upgrademodifies the database. - In Select PHP Version, check that you are using a PHP version compatible with your Magento and that
memory_limitis at least 756M (what Magento 2.4 requires; for the compilation commands, 2G is better) andmax_execution_timeis at least 300. - You need SSH access or cPanel's Terminal.
1. Install the module
Connect over SSH, go to the Magento folder and put the shop into maintenance mode:
php bin/magento maintenance:enable
If the shop is in production mode, switch it to developer while you install:
php bin/magento deploy:mode:set developer
Install the module with Composer:
composer require litespeed/module-litemage
Enable it and recompile, running the commands one at a time and checking that each one finishes without errors:
php bin/magento module:enable Litespeed_Litemage php bin/magento setup:upgrade php bin/magento setup:di:compile
Switch back to production mode (this recompiles and deploys the static files) and turn off maintenance mode:
php bin/magento deploy:mode:set production
php bin/magento maintenance:disable
If a command fails, do not carry on with the next one: copy the error and restore the backup if the shop does not load.
2. Enable LiteMage in .htaccess
Edit the .htaccess file in the Magento folder and add this at the beginning:
<IfModule LiteSpeed> LiteMage on </IfModule>
3. Select LiteMage as the cache
In the Magento admin, go to Stores > Configuration > Advanced > System, expand Full Page Cache and in Caching Application choose LiteMage Cache Built-in to LiteSpeed Server (untick Use system value first). Save.

Then go to System > Cache Management, tick Configuration and Page Cache, choose Refresh and click Submit. Check that both show as ENABLED.

Check that it works
Open a category in a private window, press F12, go to Network and reload twice. On the HTML document, the X-LiteSpeed-Cache header should show hit,litemage from the second visit onwards.
Also try adding a product to the cart, logging in as a customer and changing language or currency if you use them.
To stop using LiteMage, set Caching Application back to Built-in Cache, refresh the cache, remove the block from .htaccess and then disable the module with php bin/magento module:disable Litespeed_Litemage.
You will find more options in the official LiteMage documentation.
You may also find useful
- Integrate LiteSpeed Cache with Laravel Integrate the LiteSpeed server cache with Laravel using Composer and apply the package's middleware...
- LiteSpeed Cache for Drupal: install and set up Install the LiteSpeed Cache module on Drupal 10 or 11 with Composer and Drush, add the directives to...
- LiteSpeed Cache for Joomla: install and set up Install the LiteSpeed Cache plugin on Joomla 3, 4, 5 or 6, add the CacheLookup rule to .htaccess, ch...
- LiteSpeed Cache for MediaWiki: install and configure Install the LiteSpeed Cache extension in MediaWiki, load it in LocalSettings.php, add CacheLookup to...
Something wrong or out of date? Tell us and we will review it.