Summary
In this chapter, you learned about the various types of caching, including HTTP response caching, output caching, and object caching with in-memory or distributed, and new in .NET 9, hybrid caching, to get the best of both worlds.
Always remember that caching works best with data that (a) costs a lot to generate and (b) 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.
In the next chapter, you will learn how to write automated tests of web user interfaces using Playwright.