Performance and monitoring

Set up LiteSpeed Cache in MediaWiki

Reviewed on 3 min read rendimiento litespeed cache

LiteSpeed has a built-in cache that compatible applications can use to avoid running the same PHP over and over. The improvement depends on the cacheable content, the hit rate and MediaWiki's configuration.

LiteSpeed Cache is an extension developed by LiteSpeed to integrate MediaWiki with that cache. Check in the extension's repository that the published version is compatible with your MediaWiki branch before you install it.

Installation and setup

Before changing the site, keep a backup of the files and database that you can restore. Download a compatible version from the official repository, note which version you use and test it on a copy: downloading the main branch does not guarantee compatibility with your MediaWiki.

Unzip the file on your computer. Inside you will find a directory called LiteSpeedCache; upload that directory with the File Manager or a secure connection to MediaWiki's extensions folder.

Edit MediaWiki's configuration file LocalSettings.php and add the following line at the very end:

wfLoadExtension('LiteSpeedCache');

To complete the installation, find and edit the .htaccess file in MediaWiki's root directory and add at the very top:

<IfModule LiteSpeed>
CacheLookup on
</IfModule>

With an administrator account, go to Special pages > Data and tools > LiteSpeed Cache. The names may vary with the language.

In its options you can enable the public cache, set how long it lasts and purge the content.

Enable LiteSpeed Public Cache Enabled and save. Check the installation documentation if your version shows different names.

Check reads, changes and privacy

Visit a public page twice without logging in and check whether the later request shows a cache hit in the LiteSpeed headers. Edit a test page and confirm that the change shows up for other visitors.

Test search, logging in and logging out. If the wiki has restricted reading or private pages, check the permissions with two accounts and as a visitor: do not turn on a blanket public cache over that content.

If an error appears when loading the extension, undo the change in LocalSettings.php and check compatibility and the logs. To remove it, disable and purge its cache before removing the line that loads the extension; keep the other rules in .htaccess.

You may also find useful

Something wrong or out of date? Tell us and we will review it.