Caching means storing the result of something slow so that the next request can reuse it. It can happen at several levels:
Browser cache: static files such as images, CSS and JS, controlled with Cache-Control headers.
CDN: copies of files near the user.
Application cache: in-memory (IMemoryCache) or distributed (Redis) data, such as a list of countries or a rendered fragment.
Database or query cache: results of heavy reports.
Good candidates: data that is read often and changes rarely. Poor candidates: per-user private data (unless the key includes the user), or anything that must always be exact, such as a bank balance.
The hard part is invalidation: deciding when cached data is out of date. Use sensible expiry times, remove entries when the data changes, and add a size limit. Always make sure the page still works if the cache is empty.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Caching means storing the result of something slow so that the next request can reuse it. It can happen at several levels:
Good candidates: data that is read often and changes rarely. Poor candidates: per-user private data (unless the key includes the user), or anything that must always be exact, such as a bank balance.
The hard part is invalidation: deciding when cached data is out of date. Use sensible expiry times, remove entries when the data changes, and add a size limit. Always make sure the page still works if the cache is empty.