Question 71

1.5.3 Question

Multiple Choices

You are adding a reporting vertical to an enterprise application. Many of the reports will be run every morning by a set of users. Some of the reports will be identical as every member of a team will get the same report sometime in the morning. What kind of caching will provide an improvement in performance? (Choose all that apply.)

  • A. Data caching
  • B. Page output caching with a duration of two minutes
  • C. Page output caching with a duration of four hours
  • D. Windows AppFabric caching


A. Correct: Data caching with the appropriate timeout will enable the data needed for the reports to be stored so that the call to the database is not necessary.
B. Incorrect: Although a page output caching would be useful, the short time frame of two minutes means that the cache will likely expire before the next user requests the page.
C. Correct: A page output caching of four hours caches the output of the report for the whole morning and should eliminate the need for the report to be run a second time.
D. Correct: AppFabric caching acts much like data caching to eliminate the need for additional calls to the database to generate the reports.

Data Caching: A form of caching that can occur at the server side using the new .NET 4 Caching Framework. The default implementation uses the ObjectCache and MemoryCache objects that are within the System.Runtime.Caching assembly. When you create your cache, you can set an expiration period just as in output caching. This cache is used by all users on the server. Generally, you create a CacheProvider class that implements the ICacheProvider interface, used as an intermediate layer between the business layer and the data access layer.

Page Output Caching
[OutputCache(Duration=120, VaryByParam="Name", Location="ServerAndClient")] Public ActionResult Index() {
Return View(modelData);
This code sets the response headers so the browser will know to go to its local cache for the next 120 seconds. The Duration setting represents the time, in seconds, that the page output should be cached. Due to the Location setting in the attribute, any other browser call going to this URL will also get this same server-cached output.

Background: Web farm, or where sessions occur over many servers, each server would have to rerun the page to add it to their local cache.
Distrbuted Caching: create data on one application server and share it with the other servers
Windows Server AppFabric: Provides a set of extensions to Windows Server to enables developers to create faster, more scalable, and more manageable applications.