MediaWiki Optimization Tutorial
How to Optimize MediaWiki
MediaWiki is among the most scalable web applications. Its efficient design allows it to support sites as huge as Wikipedia while at the same time it can be perfectly optimized even for the smallest personal wiki.
MediaWiki optimization through Caching
Mediawiki supports a wide variety of caching options such as Memcache, eAccelerator, Database and others. In our case we will use a simple file caching because it works on any kind of server and does not cause additional MySQL overhead.
In order to enable the File Caching for MediaWiki please open your LocalSettings.php file. Then at the bottom add the following 3 lines:
$wgUseFileCache = true;
$wgFileCacheDirectory = "/home/YOUR_USER/public_html/cache";
$wgShowIPinHeader = false;
The first line enables the file caching option. The second line specifies in which directory the cached content should be stored. The third option is required because of a dependency.
Besides that make sure to comment (delete) the line which contains $wgMainCacheType variable in order to avoid a misconfiguration.
Finally, access your wiki pages for a while and then check the size of the "/home/YOUR_USER/public_html/cache" directory. If the cache is working this directory size should increase slowly.
Check your MySQL slow log and see what slow queries you have for the MediaWiki database. Very often slow queries are caused by certain options such as the Page Counters. Here is an example MySQL slow query:
Executed 37 min ago for 2 sec on Database --> YOUR_USER_wiki. UPDATE /* 127.0.0.1 */ `page` SET page_counter = page_counter + 1 WHERE page_id = 8
In this case you will be forced to turn off the Page Counters. For this purpose add the following lineto your LocalSettings.php file:
$wgDisableCounters = true;
Your MySQL slow logs may vary. That's why try searching for disabling the functionality associated with them.