Caching Application pages and data - Placement questions

Caching Application pages and data - Placement questions


Q.1 How many types of caching ASP.NET supports?

A) Page Output Caching
B) Partial Page Caching
C) Data Caching
D) DataSource Caching
E) All of the above.

View Answer / Hide Answer

ANSWER: E

Explanation:

Page Output Caching

Page Output Caching caches an entire page. It enables you to cache the entire contents of a page in memory. The next time that any user requests the same page, the page is retrieved from the cache.

Partial Page Caching

Partial Page Caching enables you to cache only particular regions of a page.

DataSource Caching

DataSource Caching works with the different ASP.NET DataSource controls such as the SqlDataSource and ObjectDataSource controls. When you enable caching with a DataSource control, it caches the data that it represents.

Data Caching

You can use Data Caching to cache objects in memory. For example, you can use Data Caching to cache a DataSet across multiple pages in a web application.




Q.2 You want to enable Page Output Caching in ASP.NET. What code you will write in ASPX page.

A) <%@ OutputCache Duration="30" VaryByParam="none" %>
B) <%@ OutputCache VaryByParam="none" %>
C) <%@ OutputCache Duration="30" %>
D) None of the above.

View Answer / Hide Answer

ANSWER: A

Explanation:

The Duration attribute defines the number of seconds a page is stored in the cache. The VaryByParam attribute determines which versions of the page output are actually cached.




Q.3 By default, when you use Page Output Caching, at what location page is cached?

A) Only on web server
B) Only on Client
C) Web server, any proxy servers, and browser.
D) All of the above.

View Answer / Hide Answer

ANSWER: C




Q.4 How will you specifying the Cache Location?

A) You can use browser settings to specify where a page is cached.
B) You can use the Location attribute of the <%@ OutputCache %> directive to specify where a page is cached.
C) You can use the Location attribute in QueryString to specify where a page is cached.
D) None of the above.

View Answer / Hide Answer

ANSWER: B

Explanation:

By default, when you use Page Output Caching, a page is cached in three locations: web server, any proxy servers, and browser. You can write following code to cache the page on server for 50 seconds.
<%@ OutputCache Duration="50" VaryByParam="none" Location=”Server” %>




Q.5 What is the use of VaryByParam attribute in OutputCache directive?

A) You can neglect VaryByParam attribute while using Page output caching.
B) The VaryByParam attribute determines which versions of the page output are actually cached.
C) The VaryByParam attribute determines which web page is cached in database.
D) None of the above.

View Answer / Hide Answer

ANSWER: B




Q.6 How many types of Cache Dependencies are available in ASP.NET?

A) File based dependencies
B) Key-based dependencies
C) Time-based dependencies
D) All of the above

View Answer / Hide Answer

ANSWER: D




Q.7 According to the given below statements, choose the correct option.

Statement 1: Application caching is the process of storing data (and not pages) in a cache object.
Statement 2: Page output caching stores a rendered page, portion of a page, or version of a page in memory.
Statement 3: Caching reduces the time required to render cached page in future requests.

A) Only statement 1 is correct.
B) Statement 2 and 3 are correct.
C) Only statement 3 is correct.
D) All statements are correct.

View Answer / Hide Answer

ANSWER: D




Q.8 What types of data can you store in the Cache collection?

A) Only String Type of Data
B) You can store any type of data in the Cache collection.
C) Only DataSet Object
D) All of the above.

View Answer / Hide Answer

ANSWER: B




Q.9 The type of parameter supported by OutputCache is/are?

A) VaryByParam
B) VaryByControl
C) VaryByHeader
D) VaryByCustom
E) All of the above.

View Answer / Hide Answer

ANSWER: E

VaryByParam

The VaryByParam attribute determines which versions of the page output are actually cached.
This attribute can specify which QueryString parameters cause a new version of the page to be cached. Possible values include none, an asterisk (*), and any valid query string.
Either this attribute or the VaryByControl attribute is required when you use the @ OutputCache directive on ASP.NET pages and user controls.

VaryByControl

You can provide semicolon-separated list of strings that is used to vary a user control’s output cache.

VaryByHeader

A semicolon-separated list of HTTP header used to vary the output cache. If you provide this attribute to multiple headers, the output cache contains a different version of the requested document.

VaryByCustom

This attribute is used to cache different versions of a page that depend on the type of browser and its version.




Q.10 You need to programmatically configure page output caching. Which object would you use?

A. Request
B. Response
C. Application
D. Server

View Answer / Hide Answer

ANSWER: B

Explanation:

The Response object have methods such as Response.Cache.SetExpires and Response.AddCacheDependency that enables you to configure page output caching programmatically.




Q.11 If you want to cache the page according to the browser, then what will you do?

A) Write the given below code in aspx page.
<%@ OutputCache Duration=”500” VaryByParam=”none” VaryByCustom=”browser” %>
B) Write the given below code in aspx page.
<%@ OutputCache Duration=”500” VaryByParam=”none” VaryByHeader=”browser” %>
C) Write the given below code in aspx page.
<%@ OutputCache Duration=”500” VaryByParam=” browser” VaryByCustom=”none” %>
D) None of the above.

View Answer / Hide Answer

ANSWER: A

Explanation:

If you want to create different cached versions of a page that depend on the type of browser then use the VaryByCustom attribute. This attribute accepts the special value browser. Write the code in aspx page as follows.
<%@ OutputCache Duration=”500” VaryByParam=”none” VaryByCustom=”browser” %>

If you write the above code then a page request from Internet Explorer results in a different cached version of the page than does from Firefox.




Q.12 What code you will write for using the cache object?

A) // Storing the value.
Cache["name"]="CareerRide";

// Retrieving the value on any webpage within the application.

if (Cache["name"] != null)
Label1.Text= Cache["name"].ToString();

B) // Storing the value.
Cache="CareerRide";

// Retrieving the value on any webpage within the application.

if (Cache != null)
Label1.Text= Cache.getStringValue;

C) // Storing the value.
Cache["name"]="CareerRide";

// Retrieving the value on any webpage within the application.

if (Cache["name"] != null)
Label1.Text= Cache["name"].Text;

D) None of the above.

View Answer / Hide Answer

ANSWER: A



Post your comment