Blog
Improving the speed of Semantic Mediawiki

Improving the speed of Semantic Mediawiki page load times by enforcing caching with expires header. 

I run Semantic Mediawiki on my local portable. The machine is getting on a bit, about 4 years old, but still runs Semantic Mediawiki (with the Halo extension) quite well. For some time I have been running memcache and eaccelerator with xampp under windows to produce a good result, however I recently made another discovery which radically speeds up page load times. Using Yahoo YSlow I found that  a large number of elements are used to make up a semantic mediawiki page, about 75 elements (including 29 Javascripts and 20 css) for a normal page, and it goes up to about 150 when editing a page with the richmedia editor (including 86 javascripts, and 27 css) . This means there are a large number of requests made to the server each time a page is loaded. This was in fact the slower part of the page load. Using the mod_expires and mod_headers handler of apache, I was able to make significant improvements in load times by effectively forcing the caching of static elements locally on the browser.

To do this I added the following to my httpd.conf configuration files.


1) Ensure the following lines are not commented:

LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so

2) Add the following lines just above the <Directory> directive

ExpiresActive On
ExpiresDefault "access plus 300 seconds"

3) Add the following lines just before the end of the </Directory> directive

ExpiresByType text/html "access plus 1 day"
ExpiresByType text/css "access plus 1 day"
ExpiresByType text/javascript "access plus 1 day"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 day"

Until now there seems to be no ill effects, although your mileage may vary.


Posted By: admin on Aug 11, 2010 01:53PM Add Comment