Elgg Website Speed and Performance

Hi everybody, in this post we will help you in increasing the performance and speed of your elgg website. So, shall we start?!

Note: This post is about Elgg 1.8.

Warning: Before making any changes. Please make sure to take a backup of your Website. Just in case!

Optimization Areas this post will cover:

  • Ajaxification of some areas
  • Compress Images
  • Optimize the Database tables
  • Use only necessary plugins
  • Caching the html / images and other contents
  • Avoid reloading of the engine.
  • CSS and JS Compression
  • Avoid 404

Ajaxification of some areas

Major loading time needed for elgg is in pagination and reloading of the page. You can try to add ajaxified pagination for your portfolio section, advanced plugin search functionality etc. You can also cache these ajax outputs so that it avoids repeated search query on the same contents and use ajax GET in maximum possible areas with an expiry date in future. This will avoid repeated database query and made the search in elgg faster. If you are a newbie have a look at this elgg plugin which will avoid pagination and load contents via ajax. You can also check our post http://blog.arvixe.com/how-to-ajaxify-comments-in-elgg-1-8/ .

Compress Images

Compress the maximum possible. Use png images. One of the useful tools you can use is PNGOUT Win to compress your images or any other tool you like.

Optimize the Database tables

DB optimization is always an important thing. Please check http://blog.arvixe.com/how-to-optimize-a-mysql-database-in-cpanel/ . Also, you can schedule daily cron jobs for database cleaning.

Use only necessary plugins

Always try to NOT use a lot of plugins. The more the number of plugins you are having in your mod directory, the slower will be your Elgg site. So to increase the elgg site’s speed remove all those unnecessary plugins. Keep the engine slim.

Caching the html / images and other contents

One of the things can be done is to set future expiry date for all contents like html, images, css, jss etc.. add a version tag to the theme and this will be passed to all these contents. So only if you change the version tag, these contents will be re downloaded from the server. Otherwise the browser will provide you with the cached contents. This save a lot of bandwidth, queries and increases site speed tremendously. You can create html caches for the some of the search contents, pages etc.. So the system won’t make a query to the DB, instead it will load contents from the html cache only. You can use the following code to create such a cache. Add the following code to your start.php file:

function arv_cache_exists($interval = 604800, $filename){
$filename = $_SERVER["REQUEST_URI"];
$cache_filename = "path_to_cache/".basename( rtrim( $filename, '/' ) ).".cache";
if (file_exists($cache_filename)){
if ((time() - $interval) < filemtime( $cache_filename ) ) {
return $cache_filename;
} else {
unlink ($cache_filename);
} else {
return false;
function create_arv_cache($filename){
$filename = $_SERVER["REQUEST_URI"];
$cache_filename = "path_to_cache/".basename( rtrim( $filename, '/' ) ).".cache";
$buff = ob_get_contents();
$file = fopen( $cache_filename, "w" );
fwrite( $file, $buff );
fclose( $file );

Now inside your views add the following code (this is just reference only, you need to use it wisely)

$cache_filename = arv_cache_exists(86400,'view_name');
<!-- load your html here-->
} else {

Avoid reloading of the engine

You can try with a help of a developer to process all the page / search / requests through page handlers. This will avoid the necessity of reloading the elgg engine again.

CSS Compression

You can compress Elgg css with help of css compressor. This will reduce the total size of the CSS file. The javascripts can be compressed with the help of the minify plugin.

Avoid 404

In Elgg 1.8 for every 404 page, the system has to load once. So, please make sure to cleanup your broken links etc.. You can use the following code to track your broken links.

$current_url = current_page_url();
$referer = $_SERVER['HTTP_REFERER'];
$file = 'PATH-TO-404-TRACK/404.TXT';
$fp = fopen($file, "a");
$time = date("F jS - g:i a");
fwrite($fp, $referer ." | ". $current_url . " | " . $time."n");

Please make sure to take a backup before doing anything. You should always take backup before doing any changes. I hope this post will be as beneficial as possible for you.

Looking for quality Elgg Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , | Posted under Elgg | RSS 2.0

2 Comments on Elgg Website Speed and Performance

  1. Thanks for the advice this will really come in handy. I really appreciate the info on avoiding 404. Thanks again.

  2. Actually, Minify code is now part of the core, so you don’t have to use the plugin anymore. In addition to the images loading, I would recommend Lazy Load plugin:


    It will only load images that you ‘see’ Any other images will be loaded later on.

Leave a Reply to Rodolfo Hernandez Cancel reply

Your email address will not be published. Required fields are marked *