Chapter 8: Understanding Caching
Caching is one of the key system design patterns that help in scaling any enterprise application along with improving response time. Any web application typically involves reading and writing data from and to a data store, which is usually a relational database such as SQL Server or a NoSQL database such as Cosmos DB. However, reading data from the database for every request is not efficient, especially when data is not changing, because databases usually persist data to disk and it's a costly operation to load the data from disk and send it back to the browser client (or device in the case of mobile/desktop applications) or user. This is where caching comes into play. Cache stores can be used as a primary source for retrieving data and fall back to the original data store only when data is not available in cache, thus giving a faster response to the consuming application. While doing this, we also need to ensure that the cached data is expired...