Extension:LiteSpeedCache

From mediawiki.org
MediaWiki extensions manual
LiteSpeedCache
Release status: beta
Implementation Special page
Description LiteSpeedCache is a high performance Cache solution for MediaWiki sites running in LiteSpeed Web Server.
Author(s) LiteSpeed Technologies <info@litespeedtech.com>
Latest version 1.0.0 (December 2017)
MediaWiki 1.25+
PHP 5.4+
Database changes No
Tables litespeed_settings
License GNU General Public License 3.0 or later
Download
README
Example Special:LiteSpeedCache
LiteSpeed, Webserver, Cache, Speed

The LiteSpeedCache extension is designed for MediaWiki sites running on a LiteSpeed webserver. Enable LiteSpeed's LSCache feature to speed up page loading, reduce response time, and tremendously reduce server load.

  • It's simple, easy to use, and will speed up your wiki site up to 100 times faster, after 3 minutes of setup, with no extra cost.
  • A special page integrated into MediaWiki provides full control of cache behavior.
  • No more worring about cache sync problems. LScache will automatically purge a page when related article content has changed. You can set a longer cache expiration time to improve visitor experience, confident that the cache will be purged when relevant content changes.
  • An optional private cache (for logged-in users) also will sync automatically when article content changes. No matter which user changes an article, all of the logged-in users will be served the new article content, regardless of the private cache expiration setting.

The LiteSpeedCache extension was originally written by LiteSpeed Technologies. It is released under the GNU General Public Licence (GPL v3).

Prerequisites[edit]

This version of LiteSpeedCache requires MediaWiki 1.25 or later and LiteSpeed Web Server (LSWS) 5.2.3 or later.

Code and download[edit]

You can download the LiteSpeedCache extension code in .zip format here.

You can also download the code directly via GitHub from the LiteSpeedTech source code repository. From a command line, you can call the following:

git clone https://github.com/litespeedtech/lscache_mediawiki.git

To view the code online, including version history for each file, see the GitHub repository.

Installation[edit]

Modify .htaccess file in MediaWiki site root directory, adding the following directives:

<IfModule LiteSpeed>
    CacheLookup on
</IfModule>

If your MediaWiki site has enabled MobileFrontend extension, adding the following directives:

<IfModule LiteSpeed> 
    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi [NC] RewriteRule .* - [E=Cache-Control:vary=ismobile]
    RewriteRule .* - [E=Cache-Vary:stopMobileRedirect,mf_useformat]
</IfModule>

Copy the LiteSpeedCache directory into the extensions folder of your MediaWiki installation. Then, add the following lines to your `LocalSettings.php` file (near the end):

wfLoadExtension( 'LiteSpeedCache' );

After installation, You can navigate to **Special:Version** on your wiki to verify that the extension is successfully installed.

To find a link to the LiteSpeedCache plugin, navigate to **Special:SpecialPages** on your wiki, and look under the **Data and Tools** category.

Settings[edit]

From the MediaWiki administrator panel navigate to Special pages → LiteSpeed Cache and edit that page to enable public cache:

Set LiteSpeed Public Cache Enabled to "checked" and save the page.

Verify Cache Setup[edit]

If a resource is served from LSWS cache, the server response header contains 'X-LiteSpeed-Cache: Hit'.

Load the MediaWiki site Main Page and check the headers through the Network tab of the developer tool. You should see something like this:

GET /wiki/index.php/Main_Page HTTP/1.1
Accept	text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding	gzip, deflate, br
Accept-Language	en-US,en;q=0.5
cache-control	public, max-age=2592000
server	LiteSpeed
vary	Accept-Encoding, Cookie
x-litespeed-cache	hit