1.

What are the types of caching in asp.net? Explain.

Answer»
  • Page Output Caching:

It keeps a copy of the response that was sent to the client in memory and subsequent requests are then responded with the cached output until the cache expires, which INCREDIBLY improves the ASP.NET web application performance. It is implemented by placing an OutputCache directive at the top of the .aspx page at design time.

Example: 

<%@OutputCache Duration="10" VaryByParam= "Id"%>
  • Page Fragment Caching:

Sometimes we might want to cache just portions of a page. For example, we might have a HEADER for our page which will have the same content for all users.  To specify that a user control should be cached, we use the @OutputCache directive just like we USED it for the page.

<%@OutputCache Duration=10 VaryByParam="None" %>
  • Data Caching:

Data Cache is used to store frequently used data in the Cache memory. It's much efficient to retrieve data from the data cache instead of database or other sources. We need use System.Web.Caching namespace. The scope of the data caching is WITHIN the application DOMAIN unlike "session". Every user can able to access these objects.

  • Create: Cache["Employee"] ="DatasetName";
  • Retrieve: Dataset dsEmployee = (Dataset) Cache ["Employee"]


Discussion

No Comment Found