05 August 2009
Ans:
Application object can used in situation where we want data to be shared across users globally.
» What’s the diff. between Cache object and application object ?
» What are diff. types of caching using cache object of ASP.NET?
» How can get access to cache object ?
» How can you cache diff. version using ASP.NET cache object ?
Similar articles
» What’s the diff. between Cache object and application object ?
What’s the diff. between Cache object and application object ?Ans:
The main difference between the Cache and Application objects is that the Cache object
provides cache-specific features, such as dependencies and expiration policies.
» What are diff. types of caching using cache object of ASP.NET?
What are diff. types of caching using cache object of ASP.NET?Ans:
You can use two types of output caching to cache information that is to be transmitted to
and displayed in a Web browser:
- Page Output Caching
- Page output caching adds the response of page to cache object.Later when page is requested page is displayed from cache rather than creating the page object and displaying it.Page output caching is good if the site is fairly static.
- Page Fragment Caching
- If parts of the page are changing, you can wrap the static sections as user controls and cache the user controls using pagefragment caching.
» How can get access to cache object ?
How can get access to cache object ?Ans:
The Cache object is defined in the System.Web.Caching namespace. You can get a reference
to the Cache object by using the Cache property of the HttpContext class in the
System.Web namespace or by using the Cache property of the Page object.
» How can you cache diff. version using ASP.NET cache object ?
How can you cache diff. version using ASP.NET cache object ?Ans:
Output cache functionality is achieved by using “OutputCache” attribute on ASP.NET
page header.Below is the syntax
<%@ OutputCache Duration="20" Location="Server" VaryByParam="state" VaryByCustom="minorversion" VaryByHeader="Accept-Language"%>
- VaryByParam :- Caches different version depending on input parameters send through HTTP POST/GET.
- VaryByHeader:- Caches different version depending on the contents of the page header.
- VaryByCustom:- Lets you customize the way the cache handles page variations by declaring the attribute and overriding the GetVaryByCustomString handler.
- VaryByControl:- Caches different versions of a user control based on the value of properties of ASP objects in the control.