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
Q

What is caching?

A

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

2
Q

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

A

Add the OutputCache attribute to your action method.

Ex:

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

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

A

Duration

Ex:

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

How do you use the OutputCache attribute to disable caching?

A

Set Duration to zero.

Ex:

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

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

A

Any, Client, Downstream, None, Server, ServerAndClient

6
Q

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

A

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
Q

What is donut caching?

A

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

8
Q

How is donut caching achieved in ASP.Net MVC?

A

Partial views instead of the entire page are cached.

9
Q

What is the ChildActionOnly attribute used for?

A

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();
}