Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Caching for Commerce Connect

Describes how caching is used for product catalogs and entries.

Platform cache functionality, including remote synchronization, is part of the Optimizely platform.

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

Cache subsystems

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