Different types of Caching Part 1
Why caching needed?
- If many user are trying to accessing the site, it means your server has so many requests by the user, If every request hit the server for the response then it will lead to performance issues.
- For example,if a page may contain some static information in your web site, in this scenario we can cache those content and don’t force your server to get them from data base in every request.This will increase your perfomance.
Advantage of Caching
- Reduce Database and hosting server round-trips
- Reduce network traffic
- Improve performance
Remember while using Cache :
- While caching of dynamic contents that change frequently, set minimum cache–expiration time.
- Avoid caching for contents that are not accessing frequently.
Output Cache Filter :
It’s used to cache the data that is output of an action method.In default, this will cache the data upto 60 seconds.After 60 seconds, Asp.Net MVC will execute the action method again and start caching the output again.
Let we see with example..
public class OutputCachingController : Controller