Exploring the different caching options in Umbraco
06/09/2023

Umbraco is a popular content management system (CMS) used for website development. It provides developers with a flexible and customizable platform to create dynamic websites. One of the key aspects of website development is performance, and caching plays a crucial role in improving website speed and responsiveness. In this article, we will explore the different caching options available in Umbraco and how they can be used to optimize website performance.

1. Output Caching

Output caching is a technique used to cache the rendered HTML output of a page. When a page is requested, Umbraco checks if the output is already cached. If it is, the cached output is served instead of executing the entire page generation process. This significantly reduces the load on the server and improves the response time for subsequent requests.

Umbraco provides built-in output caching capabilities that can be configured at various levels:

  • Macro Level: Output caching can be enabled for individual macros used in Umbraco. This allows specific sections of a page to be cached separately, improving performance for frequently accessed content.
  • Template Level: Output caching can be applied to entire templates, which affects all pages that use the specific template. This is useful for pages with static content that does not change frequently.
  • Partial View Level: Output caching can also be applied to partial views, which are reusable components used in Umbraco templates. This allows specific sections of a template to be cached separately, improving performance for frequently used components.

2. Distributed Caching

In addition to output caching, Umbraco also supports distributed caching, which involves caching data in a distributed cache server. This is especially useful in scenarios where multiple servers are used to host the Umbraco website.

Umbraco uses the ASP.NET Cache API, which provides a flexible and extensible framework for implementing distributed caching. By default, Umbraco uses an in-memory cache provider, but it can be easily configured to use other distributed cache providers such as Redis or Memcached.

The use of distributed caching allows Umbraco to share cached data across multiple servers, improving scalability and reducing the load on individual servers. This is particularly beneficial in high-traffic websites where performance and scalability are critical.

3. Vary by Parameter

Umbraco allows developers to specify parameters that should be considered when caching a page. This is known as "vary by parameter" caching. By default, Umbraco considers all query string parameters when caching a page, but developers can customize this behavior to include or exclude specific parameters.

For example, if a page displays different content based on a specific query string parameter, developers can configure Umbraco to cache separate versions of the page for each value of the parameter. This ensures that users see the correct version of the page based on their query string parameter value, while still benefiting from the performance improvements of caching.

4. Cache Expiration

While caching improves performance by serving cached content, it is important to ensure that the cached content is updated when necessary. Umbraco provides several options for cache expiration:

  • Time-based Expiration: Umbraco allows developers to set a time limit for how long cached content should be considered valid. After the specified time period, the cache is invalidated and the content is regenerated. This ensures that users see the most up-to-date content while still benefiting from caching.
  • Dependency-based Expiration: Umbraco also supports dependency-based cache expiration, where the cache is invalidated when a specific dependency changes. For example, if a page depends on a specific document or data source, the cache can be configured to invalidate when that document or data source is updated. This ensures that the cached content is always synchronized with the underlying data.
  • Manual Cache Clearing: In addition to time-based and dependency-based expiration, Umbraco provides developers with the ability to manually clear the cache. This can be useful in scenarios where immediate cache invalidation is required, such as when updating critical content or making configuration changes.

Conclusion

In this article, we have explored the different caching options available in Umbraco for website development. Output caching allows developers to cache the rendered HTML output of a page, improving performance by serving cached content instead of executing the entire page generation process. Distributed caching enables caching of data in a distributed cache server, improving scalability and reducing the load on individual servers. Vary by parameter caching allows developers to specify parameters that should be considered when caching a page, ensuring that users see the correct version of the page based on their query string parameter value. Cache expiration options ensure that cached content is updated when necessary, either based on time, dependencies, or manual cache clearing.

By leveraging these caching options, Umbraco developers can significantly improve the performance and scalability of their websites, providing a better user experience for visitors. Whether you are a Umbraco developer or looking to hire one for your website development project, understanding and utilizing these caching options can make a significant difference in the performance of your Umbraco websites.

Read

More Stories


19/04/2024
Mastering Content Management with Umbraco
Read More
19/04/2024
The Future of Umbraco: A Look Ahead for Open-Source Content Management
Read More
06/09/2023
The evolution of Umbraco development over the years
Read More

Contact us

coffee_cup_2x

Spanning 8 cities worldwide and with partners in 100 more, we’re your local yet global agency.

Fancy a coffee, virtual or physical? It’s on us – let’s connect!