This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
litespeed_wiki:cache:no-plugin-mediawiki [2017/09/13 14:16]
Usman Nasir created
litespeed_wiki:cache:no-plugin-mediawiki [2017/10/10 17:38] (current)
Johathan Kagan
Line 5: Line 5:
 Below are some recommended configurations to enable LSCache and get it working with your MediaWiki site(s). Below are some recommended configurations to enable LSCache and get it working with your MediaWiki site(s).
-===== Configure Server/​Virtual-Host-Level Cache Root And Cache Policy ​=====+===== MediaWiki ​=====
-Server/​Virtual-Host-level cache storage needs to be configured properly for your environmentSelect your server setup from the **Web Server Configuration** section of our [[litespeed_wiki:​cache:​common_installation#​web_server_configuration|LiteSpeed Cache Installation Guide]] and follow the instructions to set the server/​virtual-host-level cache root and cache policy.+MediaWiki is a free software open source wiki package written in PHP, originally for use on Wikipedia (the free encyclopedia). It is a feature-rich wiki implementation,​ that uses PHP to process and display data stored in its MySQL databaseIt is fairly popular wiki application on the web.
-===== Rewrite rules =====+===== MediaWiki Cache =====
-At the ''​.htaccess''​ file in the document root of your website after +With its complexity, page rendering usually takes timeTo mitigate these costs, many caching solutions have been brought up and implemented. This page (http://​www.mediawiki.org/​wiki/​Manual:​Cache) gives a good overview of caching ​in mediawiki. Among them, page caching is the one with the most performance gain. Varnish/​Squid + Mediawiki is good combination. This page (http://​www.mediawiki.org/​wiki/​Manual:​Varnish_caching) talks setup varnish with Mediawiki in details
-  # Various rewrite rules+  ​ 
-  ​<​IfModule mod_rewrite.c>​+====LiteSpeed Cache + MediaWiki====
-Add the following rewrite rules:+ We here in LiteSpeed have implemented a very simple page caching solution using LiteSpeed built-in cache for MediaWiki. Below we will outline ​the implementation in details and provide benchmarks with Varnish cache in the end.
-  ########## Begin - Litespeed cache +As everyone may know, LiteSpeed ​webserver (LSWS) cache bypasses php invocation and serves cached page directly from LSWS cacheHence a much bigger performance improvement can be achieved. The general guideline of using LSWS cache is available at http://www.litespeedtech.com/​support/​forum/​showthread.php?​t=4719. Unlike Varnish, it is built into LiteSpeed web server, eliminating one layer of reverse proxy. Hence more efficient for static contents.
-  <​IfModule LiteSpeed>​ +
-    <​IfModule ​LiteSpeed+
-     ​RewriteEngine On +
-     ​CacheDisable public / +
-     ​RewriteCond %{HTTP_COOKIE} !mediawiki_wiki__session +
-     ​RewriteCond %{HTTP_COOKIE} !mediawiki_wiki_UserID +
-     ​RewriteRule ​.* - [E=cache-control:max-age=120] +
-</IfModule>​ +
-  </IfModule>​ +
-  ########## End - Litespeed cache +
-   +
-  * The ''​CacheDisable public /''​ directive is used to help protect against globally-enabled caching and is optionalIf this directive is not used, the server'​s global cache settings should be checked ​to ensure that cache is not enabled globally. **Do NOT** use ''​CacheEnable public /''​ here as it will enable caching for all URLs belonging ​to this virtual host, including admin pages.  +In MediaWiki, everything going through index.php for processing. Using the guideline "A general way to enable LiteSpeed Cache through rewrite rules is to designate a signature token (such as cookie) in a page (or any page) in most cases to tell LSWS that cache can be enabled ​and TTL(Time ​To Live) of the cache freshness however acceptable. "we find out that, for anonymous visitors (people who don’t log in to the site), any page with no query string ​in URL is cacheable using LiteSpeed cache.
-  * We recommend using a different domain for your backend so that you can add/​edit/​preview a website'​s content through the admin domain without worrying about these changes being cached ​and seen by visitors. +
-  * To get the non-cached version of a pageadd the ''?​nocache'' ​query string ​to a URL.+
-For example:+That said, we come up with a simple set of rewrite rules in .htaccess for page caching as follows:
 <​code>​ <​code>​
-https://​www.your_domain_name.com/​about?​nocache ​ +RewriteEngine On 
 +RewriteCond %{HTTP_COOKIE} !wikidbUserID 
 +RewriteCond %{QUERY_STRING} ^$ 
 +RewriteRule ​.* - [E=Cache-Control:​max-age=300,​L]
 </​code>​ </​code>​
 +  - Cache HEAD and GET requests
 +  -     For cookie that does NOT contain "​wikidbUserID"​. (anonymous visitors)
 +  -     ​Request does NOT contain query string
 +  -     Cache TTL is set to 300 seconds (5mins).
 ===== Verify Cache Setup ===== ===== Verify Cache Setup =====
-Look for ''​X-LiteSpeed-Cache: ​hit'' in the reply headers as shown below[[litespeed_wiki:​cache:​no-plugin-setup-guidline#​verify_that_pages_are_served_from_the_cache|See more detailed directions here]].  +If a resource is served from LSWS cache, the server response header contains ​'​X-LiteSpeed-Cache: ​Hit'.
-===== Deleting Outdated Cache Files Using A Cron Job =====+
-Please refer to [[litespeed_wiki:cache:no-plugin-setup-guidline#​deleting_outdated_cache_files_using_a_cron_job|this wiki]] to learn how to clean up outdated cache files.+<​code>​ 
 +GET /​mediawiki/​index.php/​Main_Page HTTP/1.1 
 +User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:​ Gecko/​20101203 Firefox/​3.6.13 
 +Accept: text/​html,​application/​xhtml+xml,​application/​xml;​q=0.9,​*/​*;​q=0.8 
 +Accept-Language: en-us,​en;​q=0.
 +Accept-Encoding:​ gzip,​deflate 
 +Accept-Charset:​ ISO-8859-1,​utf-8;​q=0.7,​*;​q=0.7 
 +Keep-Alive: 115 
 +Connection: keep-alive 
 +Cookie: wikidb_session=ef3itaapmrdiqenjq9am4e8qv0;​ 
 +X-lori-time-1:​ 1298698098105 
 +HTTP/1.1 200 OK 
 +Content-Encoding:​ gzip 
 +Vary: Accept-Encoding,​ Accept-Encoding,​ Cookie 
 +Date: Sat, 26 Feb 2011 05:28:18 GMT 
 +Server: LiteSpeed/​4.0.20 Enterprise 
 +Connection: Keep-Alive 
 +Keep-Alive: timeout=5, max=100 
 +X-LiteSpeed-Cache:​ hit 
 +Content-Length:​ 3993 
 +X-Powered-By:​ PHP/​5.2.17 
 +Content-Type:​ text/html; charset=UTF-8 
 +Content-Language:​ en 
 +Expires: Thu, 01 Jan 1970 00:00:00 GMT 
 +Cache-Control:​ private, must-revalidate,​ max-age=0 
 +Last-Modified:​ Thu, 10 Feb 2011 05:14:38 GMT 
  • Admin
  • Last modified: 2017/09/13 14:16
  • by Usman Nasir