Area: Optimizely Commerce
Applies to versions: 14 and higher
Other versions:


Recommended reading 

This topic describes Commerce-specific caching and examples of how Optimizely Commerce uses caching for its product catalogs and their entries. Platform cache functionality, including remote synchronization, is part of the Optimizely platform.  

Classes in this topic are in the Mediachase.Commerce.Catalog namespace.

Subsystem caching

Caching options for each subsystem, such as catalogs and orders, can be configured using either AppSettings.json or the ConfigureServices method of the Startup class.

Example: Cache settings for the Catalogs subsystem, using AppSettings.json.

"EPiServer": {
   "Commerce": {
      "CatalogOptions": {
        "Cache": {
          "UseCache": true,
          "ContentVersionCacheExpiration": "00:05:00",
          "CollectionCacheExpiration": "00:05:00",
          "EntryCacheExpiration": "00:05:00",
          "NodeCacheExpiration": "00:05:00"

Example: Cache settings for the Catalogs subsystem, using Startup.

public void ConfigureServices(IServiceCollection services)
    services.Configure<CatalogOptions>(o =>
        o.Cache.UseCache = true;
        o.Cache.ContentVersionCacheExpiration = TimeSpan.FromMinutes(05);
        o.Cache.CollectionCacheExpiration = TimeSpan.FromMinutes(05);
        o.Cache.EntryCacheExpiration = TimeSpan.FromMinutes(05);
        o.Cache.NodeCacheExpiration = TimeSpan.FromMinutes(05);

The CollectionCacheExpiration responds to an entry array, and "entry" responds to a single entry. What is actually cached is the CatalogEntryDto and, because the Entry object is created from the Data Transfer Object (DTO), you cache the DTO. In some cases, you can also cache the entry objects themselves rather than the DTO.

Cache invalidation

In the Catalogs subsystem example, the cache is invalidated if it reaches the cache timeout specified above (00:05:00) for the request type, or if an object is updated. You can also invalidate cache for the entire catalog by calling CatalogCache.Clear().

Related topics

Do you find this information helpful? Please log in to provide feedback.

Last updated: Sep 28, 2021

Recommended reading