CMS Blog

Caching strategies for the Kreatio CMS: 2. Managing cache expiry

  • 19 January 2020 by
  • Senthil Kumar
Caching strategies for the Kreatio CMS: 2. Managing cache expiry

In the previous article  Caching strategies for the Kreatio CMS: 1. Introduction, we had seen how caching is implemented in the Kreatio CMS.

As we saw there, a caching strategy is only as effective as how efficiently we can expire the cache. Otherwise, we will be left with unhappy writers and readers. Readers who are unhappy at being served stale content, and writers, unhappy because their content does not appear on the site soon enough.

When content is changed, the cached content has to be purged or regenerated. As we saw in the last section, we are separately caching the entire page as well as components present within the page. So, components and pages both have to expire when the content changes.

There are two different approaches to purge stale cache - event based cache expiry or time based cache expiry.

Event based cache expiry

As the name suggest, the cache is expired on specific events.

Thus, whenever an article is created or updated, the corresponding article page cache and components cache gets purged.

If any changes were done to the Ranked List / Curated List it will purge that corresponding component and page.

Any changes done to the static pages will purge the cache of the corresponding page.

The benefits of caching will be lost if large amounts of cache are purged frequently. So we cannot rely only on event based cache expiry, particularly in a site where content is regularly updated. Thus, only those parts of the page where it is critical to update immediately like home page, latest articles component, article page etc. will be updated immediately using event based cache expiry. For other pages, the Kreatio CMS uses time based expiry.

Time based cache expiry

Here, all cached content is expired after a specific period. While doing this, we have to make sure that all the cached content should not be expired at the same time. If you do this,  it will lead to a sudden increase of requests to your application server and thus, the purpose of caching is lost.

Our caching algorithms ensure that page cache is expired in varying frequencies based on the importance, readership and age of each page. Thus, for the home page, cache is expired more frequently than for a page that has been published a while back and is no longer read frequently. The Kreatio framework has checks and balances to ensure that not all the article pages are expired at the same time, so as to avoid a sudden increase of requests to the application server.

On demand cache expiry

In spite of the best of cache expiry plans, there would still be times when the publisher needs to expire the cache of a page, on demand. The Kreatio CMS provides facilities for this also. The system administrator can select a specific page and expire its cache instantaneously, if required.

Thus, the Kreatio CMS provides a robust caching and cache expiry mechanism to meet the needs of modern digital publishing.