MediaWiki Optimization

How to Optimize MediaWiki

This tutorial covers the following topics:

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 using Caching

Mediawiki supports a wide variety of caching options such as 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, open your LocalSettings.php file. Then at the bottom add the following 3 lines:

The first line enables the file caching option.

The second line specifies in which directory the cached content should be stored. Make sure to substitute /home/cpaneluser/public_html/appfolder with the exact location of your MediaWiki script. If your cPanel username is siteground and the installation is located in a subfolder named wiki, the line would look like the one below:

The third line is set, so that all anonymous visitors to your MediaWiki see the same content, which allows improving the caching.

Besides that make sure to comment (delete) the line which contains the $wgMainCacheType variable in order to avoid a misconfiguration.

Finally, access your wiki pages for a while and then check the size of the /home/cpaneluser/public_html/cache directory. If the cache is working this directory size should increase slowly.

Optimization tweaks

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:

In this case it would be best to turn off the Page Counters. For this purpose add the following line to your LocalSettings.php file:

Your MySQL slow logs may vary. That's why you might need to search for disabling the functionality associated with them.