Configure page output cache invalidation

Leveraging output cache for your Sitefinity CMS website pages ensures your site performance and scalability. By default, when a cached version of a page is created, this version is tied to a number of dependency objects - like the content items displayed on the page, or the page template. Editing any of the dependencies causes the cached version of the page to be invalidated. This ensures that the next time the page is served, Sitefinity CMS will make a trip to the database and fetch the latest version of the page content.

This behavior has its drawbacks as well - if your site is under heavy load, and you edit a page, the cached version of the page is invalidated, and users browsing that page will access it slower initially, until a new cached version is generated. In some cases, page cache invalidation due to editing content while the site is under heavy load can cause significant performance impact. For example when you edit a page template, which is used by multiple pages, this results in invalidating the cache of all pages using that template.

To solve the above described problems, Sitefinity CMS enables you to fine-tune the page output cache invalidation behavior. When you edit a page or one of its dependencies, which would traditionally result in invalidating the output cache, you can instruct Sitefinity CMS to serve the current cache version of the page to website visitors for a predefined short period of time, and meanwhile warm-up the new version of the page in cache in the background. You can define how long Sitefinity CMS should serve the old cached version of the page when it gets invalidated, as well as whether to warm-up only the page or any content details pages, served on this page a s well.

To configure the page output cache invalidation settings follow these steps:

  1. Navigate to Administration » Settings » Advanced » System » Output Cache Settings » Page Output Cache Invalidation Settings
  2. Configure the following properties
    • Expiration Max Delay
      This setting defines the maximum amount of time (in seconds) Sitefinity CMS should serve the current cached version of a page in case of cache invalidation. For example, if you have configured 2 minuted Expiration max delay, when you publish a page, Sitefinity CMS will continue serving the current cache version of the page, and will check whether a new cache version of the page, created by the warmup task is created. If a new cached version is not found in 2 minutes, Sitefinity will automatically generate a new cache version and start serving it to website visitors.
    • Warmup
      This setting instructs Sitefinity CMS wheter to warmup pages after their cache is invalidated. By default it's set to None, meaning Sitefinity will invalidate the page output cache and serve the first request to the page without cache. To enable the warmup behavior, select one of the following values:
      • Light - this mode means that Sitefinity CMS will warmup the page once its cache is invalidated
      • Full - this mode means that Sitefinity CMS will warmup the page, and any dynamic details pages. For example, if you have a page with a News widget on it, while Light mode will warmup only the page with the list of news items, Full mode wams up also any of the news item detail pages.
  3. Click Save changes

Decide which warmup option to use

To select a warmup option that best suits your scenario you need to take two things into account - how Sitefinity CMS output cache variations work, and how your users browse your website.

Page base URL and URL parameters and filters 

By default, a Sitefinity CMS page has a base URL - the one you use to access its content. If you have a widget on the page, that displays a list of content items, each of these items has a URL, which is formed using the page base URL and the URL formatting rules for the content module. Most often, the content item URL is a combination of the page base URL and the content item URL name, which is formed using the item's Title property. For example:

UrlVariations

In this case, the content items are resolved by passing a URL parameter (the content item's URL name) to the page base URL. If yo have paging, or filtering configured for your widget, they add extra URL parameters to the base URL of the page as well, for example /page/2.

Page URL and cache variations

Each Sitefinity CMS page enters output cache using its URL as key. When you request the page, output cache is queried for that key and the cached version of the page is returned. By default, the cache version of the page is recorded using the page base URL. However, when you want to view the details of a content item on the page, the page HTML changes, and it makes sense to cache this version of the page as a separate item in output cache using a new key - the content item URL (the combination of the page base URL and the content item URL name). This is called a cache variation of the page. Each page can have multiple cache variations, depending on whether it has content items that can be displayed in details on it, and any paging or filtering that is applied to the widgets on the page. As a rule of thumb it would help understanding cache variations if you imagine each unique variation of the page URL as a separate output cache item.

Each variation is stored in output cache as a separate item with unique key, however all variations of the page use a single page compilation.Whenever a page, or its template are modified, the page's compilation is invalidated and should be precompiled. This is the slowest part of the page rendering process. Once a URL variation of a page is requested, the page is compiled, and all URL variations benefit from the compiled version of the page, thus they only need to be cached.

Full vs. Light mode

When the output cache warmup is set to Full mode, an async background task will gracefully replace all invalidated page output cache items, which have been in the cache before.  This way Sitefinity CMS always keeps an up-to-date version of all items in the cache. Of course, this mode utilizes a bit more memory and CPU resources, and there is always a chance to store items in the cache, that potentially could be never be accessed again in future. 

When the output cache warmup is set to Light mode, the output cache warmup async background task replaces only the output cache items that corresponds to the default output variations (the page base URL), leaving all other variations to be generated on demand (on first request).

Light mode still addresses the main performance problem caused by web page precompilation. We recommend to use this mode if you expect the majority of your website visitors to hit the page base URL, and not its variations.

Use Full mode if you want to ensure that any possible URL variation of your page is cached. This mode is recommended in cases where your users are highly likely to browse not only the page base URL. but also any of its variations. While more demanding on CPU and memory resources, and with potential redundancy, Full mode ensures better availability of your website..

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?