One of the core concepts in web development is caching. Understanding why we need caching is important before digging into them.
Caching helps you to reduce traffic to web server by storing some of the 'data' website requires by storing it in some form of memory, than web server serving consequent requests for the same website from that client. This will reduce the web server from redoing everything for each and every request thereby improving the performance.
Caching can be roughly divided into
- Output caching
- Application state
- Cache class
- Static member variables
Output caching
Output caching has been available since first version of ASP.NET and is also available in ASP.NET MVC as an attribute.
In ASP.NET you can add a outputcache directive for aspx page. (see example) then for the specified duration of the output cache duration setting the page will be cached.
In MVC you can decorate a action or a whole controller with outputCache attribute. (asp.net).
Above what we have done is application output caching. There's another concept called proxy output caching. (Article includes good practical example of the usage)
Output Caching is extensible. You can use custom output cache providers. Usually these Custom providers derives from OutputCacheProvider type. You can do the required configurations in Web.config.
Application state
You can store application level variables Application property of HttpContext. (link)
Cache class
Use cache class to to cache data in a ASP.NET Web application (for other types of applications you can use Memory Cache) sources: Object cache, Object caching
Static Member variables
Use Static members to store application level attributes which do not change
How to disable cache (SO)
Forcing Cache expiration
http://stackoverflow.com/questions/533867/whats-the-best-method-for-forcing-cache-expiration-in-asp-net
http://stackoverflow.com/questions/10011780/prevent-caching-in-asp-net-mvc-for-specific-actions-using-an-attribute
Links:
Forcing Cache expiration
http://stackoverflow.com/questions/533867/whats-the-best-method-for-forcing-cache-expiration-in-asp-net
http://stackoverflow.com/questions/10011780/prevent-caching-in-asp-net-mvc-for-specific-actions-using-an-attribute
Links:
- c-sharpcorner
- MSDN : Caching overview
- MSDN : 2003 Caching techniques and best practices
- SO : What is caching
- simple talk : caching the good the bad the hype
- Google search : caching in asp.net
- Tutorials Point : ASP.NET Data caching
- SO : Difference between HttpRunTime cache and HttpContext.Current.Cache
- SO : Should I use httpruntime cache
- http://www.dotnetperls.com/cache
- https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching