Commerce Engine caching
Sitecore XC solution supports two cache providers:
-
Redis - the Redis cache provider is for use in distributed deployments, including integration, testing, and production environments. By default, Commerce Engine uses Redis caching.
NoteStarting with Sitecore XC 10.2, you can use Redis Cluster for Commerce Engine caching, and for Commerce Engine Connect caching.
The Sitecore XC default deployment uses stand-alone Redis.
-
Memory - in-memory caching is for use in single-server deployments and development environments only.
ImportantIn-memory caching is deprecated in Sitecore XC release 10.2, and will be removed in a future release.
Each Commerce Engine service role has a cache store. The cache store contains multiple caches, which are grouped into data cache stores, according to the artifact store ID associated with their environment. Environments that have the same artifact store ID share the same cache data within the cache store, but their cache data is isolated from environments that have different artifact store IDs.
Sitecore XC caching follows an opt-in model, meaning that caching is disabled by default for any commerce entities and non-entities. You must explicitly enable caching for any commerce entities and non-entities that you want to cache through policy configuration.
Distributed caching
For scaled (or distributed, single-server) deployments, you can use the Redis cache provider to host a centralized cache store for the system. Each Commerce Engine service role can access the cache store and retrieve cached data, based on the environment ID specified in the request header.
A single server instance of stand-alone Redis can contain cache stores for both CE Connect caching and Commerce Engine caching. The CE Connect cache store uses DB0. The Commerce Engine cache store uses DB1.

High availability of cached data with Redis Cluster
The Sitecore XC default deployment uses Redis stand-alone, but starting with Sitecore XC 10.2, Sitecore provides basic support for Redis Cluster, for improved caching performance, failover and high availability.
There is no additional configuration required on the Commerce Engine site to use Redis Cluster.
You can use Redis Cluster for Commerce Engine caching and use either Redis stand-alone or Redis Cluster for Commerce Commerce Engine Connect caching.
Redis Cluster does not support multiple databases like the stand alone version of Redis. There is just database 0, and the SELECT command is not allowed.
Memory caching
The memory cache provider is deprecated in Sitecore XC release 10.2, and will be removed in a future release.
For single-service deployments, you can use the Memory cache provider to cache commerce items. All Commerce Engine service roles hosted on the machine use the memory cache store to retrieve cached data, based on the environment ID specified in the request header.

Cache provider configuration
The cache provider configuration is stored in the Commerce Engine config.json
file. You must enable one cache provider, and you can only enable one cache provider at a given time. The Redis cache provider is enabled by default.
},
"Caching": {
"Memory": {
"Enabled": false,
"CacheStoreName": "Commerce-Memory-Store"
},
"Redis": {
"Enabled": true,
"CacheStoreName": "Commerce-Redis-Store",
"IntervalBetweenConnectionAttemptsInSeconds": 60,
"RedisConnectionPoolSize": 1,
"RedisCompressionEnabled": true,
"Options": {
"Configuration": "PlaceholderForRedisConfiguration",
"InstanceName": ""PlaceholderForRedisInstanceName"
}
}
The following table lists and describes the configuration parameters for your cache provider:
Cache provider |
Parameter |
Default value |
Description |
---|---|---|---|
Memory |
|
|
Specifies whether the cache provider is enabled (bool.) |
|
|
Sets the name of the cache store. | |
|
|
Sets the threshold at which the cache removes the least recently used entries to make room for new entries. | |
|
|
Sets the maximum size in bytes permitted in the cache store. | |
|
|
Sets the maximum time in seconds after which the cache store updates its memory statistics. | |
|
|
Sets the maximum number of items for a cache store. If no value is specified, limitation is based on maximum size allowed in cache (as determined by the | |
|
|
Sets the minimum length of time (in seconds) between scans for expired items. | |
|
|
Sets the percentage, expressed as a decimal, of cache data to compact when the maximum size is exceeded. | |
Redis |
|
|
Specifies whether the Redis cache provider is enabled (bool.). |
|
|
Sets the name of the cache store. | |
|
|
Sets the number of seconds before a failed connection attempts to connect again. | |
|
|
Specifies the number of connections that can be created in the connection pool. | |
|
|
Specifies whether to compress cached data. | |
|
|
Specifies the connection string for the Redis cache provider. Note You can append additional Redis configuration options to the connection string to meet specific deployment requirements. | |
|
|
Sets the Redis instance name. |
Entity caching configuration
The Commerce Core plugin provides the policies that govern entity caching for the Commerce Engine.
The EntityCachingPolicy
policy defined by the Commerce Core plugin controls caching behavior for commerce entities. You can configure an entity caching policy for each entity that you want to cache. The following shows an example of the EntityCachingPolicy that defines caching configuration for entity Sitecore.Commerce.Plugin.Content.ContentPath
:
{
"$type": "Sitecore.Commerce.Core.EntityCachingPolicy, Sitecore.Commerce.Core",
"EntityFullName": "Sitecore.Commerce.Plugin.Content.ContentPath",
"AllowCaching": true,
"Priority": "Normal",
"Expiration": 86400000,
"HasNegativeCaching": true,
"CacheName": "ContentPaths",
"EntityIdPrefix": "Entity-ContentPath"
}
The following table describes the parameters in the entity caching policy configuration:
Parameter |
Default value |
Description |
---|---|---|
|
|
Sets the full name of the entity type to be cached. |
|
|
Enables or disables (bool.) caching for the entity. |
|
|
Sets the priority for the cache entry. Possible values are:
|
|
|
Sets the length of time after which a cache entry expires, in milliseconds. |
|
|
Sets the length of time after which a cache entry expires relative to the current timestamp, in milliseconds. |
|
|
Sets the length of time after which a cache entry expires if it has not been accessed, in milliseconds. |
|
|
Enables or disables (bool.) negative caching for the entity type. When set to true, it caches the fact that the entity does not exist, which prevents repeated calls to the SQL Server for entities that have been previously requested, and do not exist. |
|
Sets the name of the cache for this entity type. | |
|
The prefix to identify the entity type. |
Caching policy set
The Sitecore XC solution includes a caching policy set file that contains system caching configuration. All default environments included with the Sitecore XC solution (for example, Habitat) reference the default caching policy set.
The Plugin.Caching.PolicySet-1.0.0.json
file is stored in the wwwroot\data\Environments folder and contains caching policies for commerce entities and non-entities.
The caching policy set contains policy configuration for the following commerce entity caches:
-
Content paths cache
-
Content items cache
-
Shops cache
-
Policy Sets cache
-
Entity Indexes cache
-
Promotions cache
-
Promotion Books cache
-
Catalogs cache
-
Categories cache
-
Relationship Definitions cache
-
Sellable Items cache
-
Inventory Sets cache
-
Price Cards cache
-
Price Books cache
-
Localization Entities cache
-
Versioning Entities cache
-
Workflows cache
-
Search Statuses cache
In addition, the Caching policy set contains caching policy configuration for the following non-entity items:
-
Management cache (caches item model objects from the Commerce Control Panel)
-
Custom Relationships cache (caches a list of custom relationships)
-
Associated/Disassociated Catalogs cache (caches a list of associated and disassociated catalogs for each promotion book)
-
Localized Terms cache (caches a list of commerce localized terms)
-
Customer Statuses cache (caches a list of localized customer statuses)
-
Returns cache policy (caches a list of localized reasons-for-returns)
Caching API commands
You administer caching through the CommerceOps API. You can use the Postman samples (located in the SitecoreCommerce_DevOps collection) to execute the caching commands.
-
Starting with Sitecore XC 10.2, the CommerceOps API service is configured to work against the Commerce Engine instance running the Authoring service. Sitecore XC deployment no longer creates a DevOps Commerce Engine instance.
-
In-memory caching is deprecated in Sitecore XC 10.2, and will be removed in a future release.
The following table lists the API commands for caching:
Command |
Postman sample |
Description |
---|---|---|
|
Get cache stores |
Retrieves all the cache stores in the system. |
|
Get cache store |
Retrieves a named cache store. |
|
Get data cache store |
Retrieves the caches within the cache store that match the environment's artifact store ID. |
|
Get cache |
Retrieves a named cache. If the cache is not present in the cache store, the system returns a 404 error. |
|
Clear cache store (Deprecated) |
Clears all the caches within the cache store. Note This command is intended for in-memory caching. |
|
Clear data store caches (Deprecated) |
Clears all caches in the data store. The Commerce Engine determines the data store from the environment name specified in the request header. Note This command is intended for in-memory caching. |
|
Clear cache |
Clears the named cache within a cache store. Note This command is intended for Redis or in-memory caching. |
|
ClearCachesForArtifactStore (Redis only) |
Clears all caches that share the specified artifact store id in the target environment. |
|
ClearAllCaches (Redis only) |
Clears all default Commerce caches in all environments, including the global environment. Note This command only clears default Commerce Engine caches. To clear your custom caches, use the |