I am using the awesom MVCDonutCaching package from Nuget in order to cache entire pages while leaving certain portions uncached. The process is simple and everything works as it should:
I am caching as follows:
[DonutOutputCache(CacheProfile = "FiveMins")]
public ActionResult Index()
{
return View();
}
For the section of my page I do not wish to cache I am doing the following:
@Html.Action("HeaderLinks","Home", true)
This works as it should and indeed the bulk of the page is cached but my header links - context sensitive links displaying a log on button if the user is not logged in, their username if they are, etc. - is not cached. So far everything works.
The problem that I am having is that the headerlinks belong to a master/layout page and are used across the board - regardless of whether an Action has a DonutOutputCache attribute set or not. When I create another action, let's call it 'about us', without a donut caching attribute I do not see my header links at all
public ActionResult AboutUs()
{
return View();
}
Looking at the source code I see the following
<!--Donut#
<ActionSettings xmlns="http://schemas.datacontract.org/2004/07/DevTrends.MvcDonutCaching" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ActionName>HeaderLinks</ActionName>
<ControllerName>Home</ControllerName>
<RouteValues xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:KeyValueOfstringanyType>
<a:Key>Area</a:Key>
<a:Value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema"/>
</a:KeyValueOfstringanyType>
</RouteValues>
</ActionSettings>
#-->
Obviously in the above example, which is generated by the donut caching library - the links section is replaced by some commented XML.
My question in a nutshell is: is it possible with this library to reuse the same child action regardless of whether the parent action is using donut caching or not?
Any help would be appreciated.