What would be the best way to cache an actionresult forever, that is untill the application is restarted.
// Cache this result forever, it will reset on app restart
[OutputCache(Duration=999999)]
[ChildActionOnly]
public ActionResult Footer()
{
if (HttpContext.Application != null && HttpContext.Application.AllKeys.Contains("Version"))
return Content(HttpContext.Application["Version"].ToString());
return null;
}
Is there a better way to do this?
I don’t know a better way. You can create your own attribute
ForeverOutputCache, which will setDuration = Int32.MaxValuein constructor, but this is almost same approach.