How do I enable LiteMage Caching for my Magento 2.X Store?

LiteMage Cache works like Apache mod_cache or Varnish, but is implemented in a more efficient way. LiteMage Cache uses the LiteMage Magento extension and an improved version of LS Cache to deliver superior caching with ESI implementation geared specifically for Magento.

1. Requirements before commencing LiteMage activation
2. How do I Enable LiteMage Caching for my Magento Store?
3. Install the Magento LiteMage extension
4. Configure the Magento LiteMage extension
5. Troubleshooting

Requirements before commencing LiteMage activation

1. LiteMage cache can only be used on our Stealth plans
2. This guide is only to be used for Magento 2.X and above
3. Magento 2 requires PHP versions 7.0.2+, 5.6.x, or 5.5.x, we recommend using PHP 7.X for maximum performance.
- To check what version of PHP you're using and change it to one of the recomended version above please follow this guide
4. Make sure you disable all 'Full Page Cache' extensions – since these will interfere with LiteMage and may cause issues. Examples of these extensions include 'Extendware Full Page Cache'
5. If you are using Magento Compilation (System → Tools → Compilation) then you should disable it first before installing any Extensions.

How do I Enable LiteMage Caching for my Magento Store?
Add the following code to the .htaccess file located in the directory serving your Magento instance (eg. public_html)

<IfModule Litespeed>
LiteMage on

Install the Magento LiteMage extension

1. Log into shell (SSH), if you do not have SSH enabled please use the following guide

2. Enter the directory where Magento 2 is installed (eg. if your Magento 2 instance is located in the public_html then "cd public_html" via shell to enter the public_html directory).

cd public_html

3. Set the store to developer mode

php bin/magento deploy:mode:set developer

Once completed the following will be outputted:

Output: Enabled developer mode.

4. Download the zip package file from this repository:


5. Unzip the package
The below will unzip all files/folders into the directory 'magento2-LiteSpeed_LiteMage-master', do not enter this directory yet.


6. In the Magento 2 root directory (eg. public_html), run the following command to create the needed directories:

mkdir -p app/code/Litespeed/Litemage

7. Move the contents from the GitHub directory to the newly created directory:

mv /path/to/magento2-LiteSpeed_LiteMage-master/* app/code/Litespeed/Litemage/

8. While still in the public_html directory, execute the following command:

mv magento2-LiteSpeed_LiteMage-master/* app/code/Litespeed/Litemage/

The above will move the contents from the GitHub directory to the newly created directory.

9. Enable LiteMage 2 in Magento:

php bin/magento module:enable Litespeed_Litemage

10. Upgrade the Magento setup:

php bin/magento setup:upgrade

11. Recompile using the signal tenant compiler or multi-tenant compiler.

If you have one website and store, please run:
php bin/magento setup:di:compile

If you have multiple websites and stores, please run:
php bin/magento setup:di:compile-multi-tenant

12. Once finished, delete var/di/relations.ser to work around a Magento bug, you'll only be required to remove it if the file exists, otherwise skip this step.

rm var/di/relations.ser

13. Switch back to production mode.

php bin/magento deploy:mode:set production

14. Once switched back to production mode, delete var/di/relations.ser to work around a Magento bug.

rm var/di/relations.ser

Configure the Magento LiteMage extension
Note: The Magento LiteMage Extension is disabled by default. You can enable or disable the extension easily from inside the Magento Admin Configuration Panel.

1. Login to the Magento Admin Panel using your login credentials.
2. Navigate to Stores → Configuration → Advanced → System.
3. Select 'Full page Cache'
4. Set 'Caching Application' too 'LiteMage Cache in LiteSpeed WeServer'
5. Select 'Save Config'
6. Navigate to System → Cache Management and under Cache Storage Management check the box next to Configuration.
7. Click the 'Submit' button to refresh the cache.

You've now successfully installed LiteMage Cache for Magento 2.X and above.


How to check if a page is served from LiteMage Cache or not
Use your browser's developer tool to check response header. If you see header "X-LiteSpeed-Cache: hit,litemage", that means the page is served by litemage cache.

How do I clear or flush the LiteMage Cache?
Once LiteMage Cache has been enabled, a 'Flush LiteMage Cache' button will show up under System → Cache Management. If you click the buttons 'Flush Magento Cache' or 'Flush Cache Storage' it will automatically flush the LiteMage Cache.

How to temporarily turn off LiteMage for certain URL from browser
Sometimes you may want to check if an issue is caused by LiteMage Cache being enabled but do not want to disable LiteMage Cache for everyone. You can add the following parameter "LITEMAGE_DEBUG=NOCACHE" to the end of the URL and the page will not be served from LiteMage Cache. For example if your URL to a page in your Magento store is you would change it to to view the page not served by LiteMage cache.

Can I enable LiteMage cache for just my IP address only for testing purposes?
Yes, and it is highly recommended to do so especially on production servers. To enable this, go to Magento Admin → System → Configuration → LITEMAGE CACHE → LiteMage Configuration → Developer Testing → Enable LiteMage Cache Only for Listed IPs