Table of Contents

Class CacheOptions

Namespace
Microsoft.Identity.Client
Assembly
Microsoft.Identity.Client.dll

Options for MSAL token caches.

public class CacheOptions
Inheritance
CacheOptions
Inherited Members

Remarks

Detailed cache guidance for each application type and platform, including L2 options: https://aka.ms/msal-net-token-cache-serialization

Constructors

CacheOptions()

Constructor for the options with default values.

public CacheOptions()

CacheOptions(bool)

Constructor

public CacheOptions(bool useSharedCache)

Parameters

useSharedCache bool

Set to true to share the cache between all ClientApplication objects. The cache becomes static. UseSharedCache for a detailed description.

Properties

EnableSharedCacheOptions

Recommended options for using a static cache.

public static CacheOptions EnableSharedCacheOptions { get; }

Property Value

CacheOptions

UseSharedCache

Share the cache between all ClientApplication objects. The cache becomes static. Defaults to false.

public bool UseSharedCache { get; set; }

Property Value

bool

Remarks

Recommended only for client credentials flow (service to service communication). Web apps and Web APIs should use external token caching (Redis, Cosmos etc.) for scaling purposes. Desktop apps should encrypt and persist their token cache to disk, to avoid losing tokens when app restarts. ADAL used a static cache by default.