Design the application architecture - Objective 1.5: Design a caching strategy Flashcards Preview

Exam 70-486: Developing ASP.NET MVC 4 Web Applications > Design the application architecture - Objective 1.5: Design a caching strategy > Flashcards

Flashcards in Design the application architecture - Objective 1.5: Design a caching strategy Deck (9)
Loading flashcards...
1

What is caching?

A strategy to improve performance by storing frequently used information in high-speed memory.

2

How do you implement page output caching in ASP.Net MVC?

Add the OutputCache attribute to your action method.

Ex:

[OutputCache(Duration=120, VaryByParam="Name", Location="ServerAndClient")]
public ActionResult Index()
{
return View("Index", myData);
}

3

Which property of the OutputCache attribute is used to configure the length of time to cache an action's result?

Duration

Ex:

[OutputCache(Duration=120, VaryByParam="Name", Location="ServerAndClient")]
public ActionResult Index()
{
return View("Index", myData);
}

4

How do you use the OutputCache attribute to disable caching?

Set Duration to zero.

Ex:

[OutputCache(Duration=0)]
public ActionResult Index()
{
return View("Index", myData);
}

5

What are the valid values for the Location property of the OutputCache attribute?

Any, Client, Downstream, None, Server, ServerAndClient

6

What is the VaryByParam property of the OutputCache attribute used for?

Specifies the query string or form parameter names to store different versions of the cached output.

In the example code below, the output will be cached separately for each distinct value passed for Name in the query string of the request.

Ex:

[OutputCache(Duration=120, VaryByParam="Name", Location="ServerAndClient")]
public ActionResult Index()
{
return View("Index", myData);
}

7

What is donut caching?

Allows caching of an entire page except for the dynamic parts of the page.

8

How is donut caching achieved in ASP.Net MVC?

Partial views instead of the entire page are cached.

9

What is the ChildActionOnly attribute used for?

Only allows the action to be called from Action or RenderAction HTML extension methods.

Ex:

[ChildActionOnly]
[OutputCache(Duration=60)]
public ActionResult ProductsChildAction()
{
// Fetch products from the database and
// pass it to the child view via its ViewBag
ViewBag.Products = Model.GetProducts();
return View();
}