It is possible to easily cache the rendering of a web page using a custom condition by setting a custom string, which ASP.NET will vary the output by. To test it, you need to create a class that inherits from MvcOutputCacheAttribute. Take a look at the following example:
public class VaryByBrowser : Verndale.OutputCache.Attributes.MvcOutputCacheAttribute
{
protected override string GetVaryByCustomString(ControllerContext filterContext)
{
if (PageEditing.PageIsInEditMode)
{
return null;
}
return filterContext.HttpContext.Request.Browser.Browser;
}
}
In this case, our caching will be varied based on which browser the user accesses the page with. The action method in the controller should be decorated like this:
public class MyController : PageController<Page>
{
[VaryByBrowser]
public ActionResult Index(Page currentPage)
{
var model = PageViewModel.Create(currentPage);
return View(model);
}
}
Try accessing the page from different browsers. You will see that the output now depends on which browser you use.
It is perhaps not the solution to all your problems but it shows a nice utility of Output Caching.