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?
ASP.NET Core WebAPI: Memory Caching vs Response Caching
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
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.
© 2022 - 2024 — McMap. All rights reserved.