Tuesday, February 2, 2010

Explain the types of Caching using Cache object of ASP.NET

  • Page output: Is used to fetch information or data at page level. It is best used when the site is mainly static. Used by declaring the output page directive
  • Page fragment: Is used to cache the structure level information. It is used when parts of pages change. For example: user control
  • Programmatic or data: Is used to fetch the information of an application quickly based on the requirements.

Show with an example how to Cache different version of same page using ASP.NET Cache object.

The ways to cache different versions on the same page using ASP.NET cache object is using OutputCache object.
Three parameters of OutputCache, has 3 parameters:
  • VarByParam: based on input parameters passed through HTTP POST/GET.
  • VarByHeader: based on the page header content.
  • VayByCustom: based on declaration of an attribute and overriding GetVaryByCustomString handler.
VarByControl: varies with the value of properties of ASP objects

0 Comments: