Configuring web application caching (.NET)

DXA caches multiple levels of data; however, you can modify this default behavior and disable specific handlers and regions. To configure .NET client-side caching behavior, modify the web application definition, Web.config.

Procedure

  1. In your DXA .NET web application, open Web.config for editing.
  2. Find the sdl.web.delivery section and the caching child section.
    You see two sections within caching:
    handlers
    This section specifies the kind of caching handlers (that is, the types of cache) you can handle:
    Cache handlerDescription
    noCachePerform no caching at all.
    regularCachePerform in-memory caching that expires quickly. This is the default, as indicated by the defaultHandler attribute of the parent caching element.
    longLivedCachePerform in-memory caching that expires slowly.
    regularDistributedCachePerform caching in a Redis database that expires quickly.
    longLivedDistributedCachePerform caching in a Redis database that expires slowly.
    regions

    This section contains a number of add elements that specify which kinds of items to cache (indicated by the name attribute) and which kind of cache to store those kinds of items in (indicated by the cacheName attribute).

  3. By default, DXA performs in-memory caching. If you want to perform distributed caching, do the following:
    1. If you have not yet set up a Redis database, do so now. (You can download Redis from https://redis.io/download.)
    2. In the endpoint child elements, specify the host name and port of your Redis database.
    3. Within the regions section, change every regularCache to regularDistributedCache, and change every longLivedCache to longLivedDistributedCache.
  4. To change the definition of "quickly" or "slowly" (as mentioned in step 2), in the policy child element of the add element of the handler you use, change the value of the absoluteExpiration attribute to a different number of seconds.
  5. To change the cache lifetime of a specific region or regions, change the cache handler specified in the cacheName attribute from regularCache to longLivedCache or vice versa, or from regularDistributedCache to longLivedDistributedCache or vice versa.
  6. Save and close the file.
  7. Restart the web server.

What to do next

For more information about configuring client-side caching, refer to the Tridion Sites product documentation.