Improving performance: towards a better user experience

By ,

While implementing permissions, it became quite clear that XirtCMS was quite poorly optimized with regard to database data retrieval. Even while rendering a simple web page (for e.g. the current XirtCMS homepage), the number of queries required was already nearing the thirties retrieving a lot of similar information from the database. For example, several widgets and modules were all requesting information on a specific author (user), causing a lot if redundant database look-ups. It became quite clear that optimization was required to keep response times acceptable. In this article, two of the main improvements that recently have been implemented are put in the spotlight.

Model Caching

To prevent redundant retrieval of data, a new caching functionality has been introduced in a library called XCMS_Cache. This new library has an internal storage (basically an Array) and methods to save and retrieve data from this storage. Items can be stored and retrieved from this cache using a unique String identifier (for e.g. the identifier user.1 is used by the application to store the retrieved model for a user with ID #1). To reap the benefits from this new library, other model helpers were rewritten to include public methods allowing retrieval of one or more related models. These new helper methods leverage the new caching functionality thereby reducing calls to the database: instead of retrieving and processing information on specific users on each call, XCMS_Cache is used only perform this activity once per page request.

Output Caching

A second optimization was implemented using the default CodeIgniter caching functionality (described here). This library enables developers to cache data to a file or memory for usage during subsequent requests. XirtCMS now leverages this functionality to temporarily cache output for modules and widgets: once output is generated, the application will use a cached version of the output for a predetermined amount of time before attempting to recreate the output. This enables XirtCMS to bypass database retrieval and coding logic for subsequent requests significantly reducing page rendering time. Furthermore, the backend of XirtCMS is being altered to provide administrators the option to set the cache expiry time per widget or disable caching completely.


With both improvements implemented, a test was run on the production website of XirtCMS to perform a quick performance impact. Having quite a slow server (unfortunately, our host has a TTFB for a static file of already 50ms), it would have been great if the server would be able to respond within 250ms for (subsequent) requests and load the pages in 500ms limiting impact on the user experience. And as you can see below, for most requests this goal has now been achieved as the average full page loading time has been halved to 0.444 seconds:

Performance after improvements (average 0.965s) Performance after improvements (average 0.444s)

Responses (0)

There are no responses to display. Be the first to react!

About the author

A. Gideonse

A. Gideonse

Arno enjoys programming in his spare time and created XirtCMS as a lean and fast platform to develop his ideas on. On this website, you will find all information required to start using XirtCMS and/or extend its functionality yourself.

XirtCMS - Copyright © 2018. All rights reserved. | GNU General Public License v3.0