Caching with ASP.NET Core
Caching can enable our systems to copy some data from a remote data center to a local data center, or from a server or disk to memory. Caches store data as key-value pairs.
However, one of the hardest parts of caching is getting the balance right between storing enough data and keeping it fresh. The more data we copy, the more resources we use. And we need to consider how we will keep the copies synchronized with the original data.
General caching guidelines
Caching works best with data that costs a lot to generate and does not change often.
Follow these guidelines when caching:
- Your code should never depend on cached data. It should always be able to get the data from the original source when the data is not found in the cache.
- Wherever you cache data (in-memory or in a database) it is a limited resource, so deliberately limit the amount of data cached and for how long by implementing expirations and size limits. You should...