Sitecore Recommended Cache Settings

S

Optimizing Sitecore Caching for Faster Page Loads

For modern websites, speed is everything. Research shows that even a 1-second delay in page load time can cause a 7% loss in conversions. With the average attention span getting shorter all the time, slow-loading pages are a quick way to lose visitors.

Faster Sitecore new scaled

For content management systems like Sitecore, optimizing caching is one of the most impactful ways to improve site performance. Effective use of Sitecore's robust caching capabilities can dramatically speed up page load times, but the settings need to be tuned properly for each unique situation.

Below we'll explore Sitecore's various caching features and best practices for configuring cache settings depending on factors like traffic patterns, content update frequency, and more. With the right strategy, you can leverage caching to deliver lightning-fast page loads that engage users.

An Overview of Caching in Sitecore

Sitecore offers several different cache types that store data in memory for faster retrieval. The main ones are:

Caching system in Sitecore.png
  • HTML Cache - Caches the fully rendered HTML output for pages to avoid repetitive backend rendering on each request.
  • Data Cache - Caches raw data items retrieved from the database so they don't have to be queried every time.
  • Registry Cache - Stores system-level .NET objects like configurations and dependency injection registrations.
  • Query Cache - Caches the datasets returned by content queries.
  • Object Cache - Provides general-purpose caching for arbitrary application data like API responses.

Caching speeds things up by avoiding unnecessary backend work on repeated requests. However, it takes some extra tuning and system resources. The trick is maximizing the performance benefits while minimizing any downsides.

Key Caching Factors to Consider

There are several key factors to evaluate when configuring Sitecore caching for optimal performance:

Key Caching Factors to Consider

Configuring Sitecore Caching Settings

With those factors in mind, let's look at how to configure Sitecore's various cache types for optimal results.

Setting HTML Cache Expiration

The HTML cache expiration timeout determines how long a page's rendered output stays cached in memory. This is set in the <htmlCache> section of Sitecore.config.

Typical HTML cache lifetimes range from 5 minutes to 24 hours. Shorter expirations accommodate frequent content changes, while longer values provide more performance benefit.

Consider setting HTML cache expiration to:

  • 5-15 minutes for extremely dynamic sites with edits multiple times an hour.
  • 2-6 hours for average content sites with fairly regular publishing.
  • 12-24 hours for highly static sites with infrequent updates.

You can also set exceptions for certain site sections - like caching product category pages for longer periods.

Configuring the Data Cache

The data cache stores raw content retrieved from the database for reuse. This helps avoid hitting the database with the same queries repeatedly.

The standard data cache size is 50MB per Sitecore instance - suitable for average sites. For large data sets and high traffic sites, increase the size to 200-500MB or more.

You can set different data cache sizes per database by defining <dataCache> configs for each one under <databases>. Monitor cache hit ratios over time and tweak sizes accordingly.

Data cache expiration is also important. The default lifetime is 20 minutes, which suits moderately dynamic content. For more static sites, consider values like 1-6 hours to improve cache hits.

Tuning the Registry Cache

The .NET registry cache stores application-level objects like Sitecore configurations, services, and more. This avoids expensive rebuilding of these objects on each request.

The default registry cache size is 15MB. For high-traffic sites, increasing to 25-50MB can help minimize registry cache misses and rebuilds.

Unlike other caches, the registry cache does not expire items. Entries only invalidate if dependent objects change during an app restart. Keep the size in check on memory-constrained systems.

Enabling the Query Cache

Sitecore's query cache stores results of content queries - avoiding repetitive queries on each page view. This requires enabling the <enableQueryCache> setting.

The default query cache size is 5MB. Boost this to 25-100MB for query-heavy public sites. Monitor cache statistics over time and adjust as needed.

Also, set explicit cache expiration timeouts on high-value queries. The default is 30 minutes, but you can go up to 24 hours for extremely static result sets.

Leveraging the Object Cache

Sitecore's general object caching is great for storing shared data like external API responses. This avoids the overhead of calling those services repeatedly.

The standard object cache size is 5MB. For object cache-heavy scenarios like headless, increase to 50-200MB based on traffic and data volumes.

Tune object expiration timeouts based on the dynamics of each cached item. For example, 24 hours for rate limit statuses from an API provider.

Profiling Cache Usage

Once you've configured caching settings, profile your cache usage over time:

  • Monitor hit ratios - This reveals how well cache sizes are tuned. Tweak sizes up or down to aim for high hit percentages.
  • Check expiration efficiency - See if expiration timeouts are appropriate based on hits within those windows. Adjust timeouts as needed.
  • Identify cache-friendly pages - HTML cache hits highlight pages best suited for full page caching. Focus optimization efforts there.
  • Fix cache bottlenecks - Isolate any overly shared cached objects that cause contention. Break them into smaller domain-specific caches.

With data-driven refinements over time, you can achieve highly optimized Sitecore caching and blazing fast load times. Proper caching is one of the best and most cost-effective performance wins available.

Achieving Cache Zen

Caching is a complex balance with many factors in play. There is no single best practice - only optimal settings for each unique situation. Like a Zen master, strive for cache enlightenment through continuous learning and refinement.

With a data-driven approach, you can maximize Sitecore caching benefits while minimizing resource usage and complexity. Fast page loads lead to happy users, and happy users lead to successful sites.

Index