Posts

Showing posts from May, 2024

ASP.NET Core | What is Distributed caching?

Applications running on multiple servers (Web Farm) should ensure that sessions are sticky. For Non-sticky sessions, cache consistency problems can occur.  Distributed caching  is implemented to avoid cache consistency issues. It offloads the memory to an external process. Distributed caching has certain advantages as below. Data is consistent across client requests to multiple server Data keeps alive during server restarts and deployments. Data does not use local memory IDistributedCache  interface instance from any constructor enable distributed caching service via  Dependency Injection .

ASP.NET Core | What is In-memory cache?

In-memory cache  is the simplest way of caching by ASP.NET Core that stores the data in memory on web server. Apps running on multiple server should ensure that sessions are sticky if they are using in-memory cache. Sticky Sessions responsible to redirect subsequent client requests to same server. In-memory cache can store any object but distributed cache only stores  byte[]. IMemoryCache  interface instance in the constructor enables the In-memory caching service via ASP.NET Core dependency Injection.

ASP.NET Core | Caching or Response caching in ASP.NET Core

Caching  significantly improves the performance of an application by reducing the number of calls to actual data source. It also improves the scalability. Response caching is best suited for data that changes infrequently. Caching makes the copy of data and store it instead of generating data from original source. Response caching headers control the response caching.  ResponseCache  attribute sets these caching headers with additional properties. In-memory caching In-memory caching uses server memory to store cached data. This type of caching is suitable for a single server or multiple servers using session affinity. Session affinity is also known as  sticky sessions . Session affinity means that the requests from a client are always routed to the same server for processing. Distributed Cache Use a distributed cache to store data when the app is hosted in a cloud or server farm. The cache is shared across the servers that process requests. A client can submit a requ...

ASP.NET Core | Open Web Interface for .NET (OWIN)

Image
ASP.NET Core supports the Open Web Interface for .NET (OWIN). OWIN allows web apps to be decoupled from web servers. It defines a standard way for middleware to be used in a pipeline to handle requests and associated responses. ASP.NET Core applications and middleware can interoperate with OWIN-based applications, servers, and middleware. Running OWIN middleware in the ASP.NET pipeline ASP.NET Core’s OWIN support is deployed as part of the  Microsoft.AspNetCore.Owin  package. You can import OWIN support into your project by adding this package as a dependency in your  project.json  file: "dependencies" : { "Microsoft.AspNetCore.Server.IISIntegration" : "1.0.0" , "Microsoft.AspNetCore.Server.Kestrel" : "1.0.0" , "Microsoft.AspNetCore.Owin" : "1.0.0" }, OWIN middleware conforms to the  OWIN specification , which requires a  Func<IDictionary<string,   object>,   Task>  interface, and...