Skip to content
Last update: May 8, 2024

Cache Configuration

Cache is commonly configured in the Caching section of the appsettings.json file:

Configuration Settings

The configuration keys are hierarchical, and the most convenient way to manage them is to work with the appsettings.json file. The following sections, organized by configuration node and alphabetically, show the general structure of the file, provide defaults, and explain what each key is.

Note

All settings listed below are optional unless marked Required.

Node Default or sample value Description
Redis Redis configuration. Includes the message channel to use and the number of retries.
CacheEnabled
  • true
  • false
  • Cache entries are retained based on the expiration settings.
  • Disables caching of application data for the entire application.
Used when ConnectionStrings:RedisConnectionString is not specified.
CacheSlidingExpiration "0:15:00" The cache entry will expire if it is not accessed for a specified amount of time.
Used when CacheAbsoluteExpiration is not defined.
CacheAbsoluteExpiration "0:5:00" The cache entry will expire after a specified amount of time.
Used when RedisConnectionString is not specified.

Examples

appsettings.json
 "Caching": {
       "CacheEnabled": true, 
       "CacheSlidingExpiration": "0:15:00", 
       //"CacheAbsoluteExpiration": "0:15:00"
    }
appsettings.json
"Redis": {
"ChannelName": "VirtoCommerceChannel",
"BusRetryCount": 3
} 

Note

CacheSlidingExpiration or CacheAbsoluteExpiration set a sliding or absolute expiration time for all cached application data that does not have a manually configured expiration value.