ASP.NET Core Web API Interview Question #137

What is distributed caching?

Error Handling, Logging, Caching, Rate Limiting, CORS & Reliability Senior Advanced

Quick Interview Answer

A distributed cache is shared by multiple application instances, commonly through a dedicated system such as Redis or another supported distributed-cache provider. It can support consistent cached data across a scaled-out API.

Detailed Explanation

A distributed cache is shared by multiple application instances, commonly through a dedicated system such as Redis or another supported distributed-cache provider. It can support consistent cached data across a scaled-out API.

Distributed caching adds network calls, serialization, availability concerns, and invalidation complexity. Use it where shared caching provides measurable value.

Code Example

builder.Services.AddStackExchangeRedisCache(options =>
{
    options.Configuration =
        builder.Configuration.GetConnectionString("Redis");
});