Cătălin Rădoi
Cătălin Rădoi

Reputation: 1894

OutputCache an ActionResult that only returns a View

Would it make sense to [OutputCache] something like this?

[HttpGet]
public ActionResult About()
{
    return this.View("About");
}

Upvotes: 0

Views: 99

Answers (1)

Md Rahatur Rahman
Md Rahatur Rahman

Reputation: 3244

It depends on what is in the View. For example if it a heavier view and the output is same for all the users then yes you should use the [OutputCache] filter. This will reduce the timing on the server side for:

  • View relocation
  • View parsing

When you use the [OutputCache] filter consider setting the parameters properly. i.e. cache duration and others as needed.

Upvotes: 1

Related Questions