Search code examples
c#asp.net-mvccachingoutputcache

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

Solution

  • 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.