ASP.NET Core WebAPI: Memory Caching vs Response Caching
Asked Answered
C

1

9

ASP.NET Core provides both in-memory caching and response caching. Let's say that the app is ASP.NET Core WebAPI that brings data from SQL database to users with configured Responce Caching middleware. In what case is it useful to use a memory caching also?

Clardy answered 19/6, 2018 at 9:48 Comment(1)
They're two different things, and one doesn't necessarily involve the other. However, it's very likely (especially if you haven't configured something like Redis or SQL Server caching) that your response cache is memory cache.Engraft
R
16

These caching strategies are supposed to play a quite different role:

  • Response caching is used to say clients that communicate with a server to cache the response on their side using specific headers (such as Cache-Control, Expires, etc). Response Caching middleware adds required headers to the response.
  • In-memory caching helps you to store the data that changes infrequently and is used during request processing. E.g. you support currency conversion for product prices and use some third-party service to obtain conversion rates. If you know that service updates the rate once per day, you can store it in an in-memory cache to speed up request processing, since you don't need to call that service again for some time.
Roseroseann answered 19/6, 2018 at 11:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.