MVCDonutCaching - problems with a child action when a parent is not cached

I use the awesom MVCDonutCaching package from Nuget to cache entire pages, leaving some portions without access. The process is simple and everything works as it should:

I cache as follows:

[DonutOutputCache(CacheProfile = "FiveMins")] public ActionResult Index() { return View(); } 

In the section of my page I do not want to cache, I do the following:

  @Html.Action("HeaderLinks","Home", true) 

This works as it should, and the main part of the page is cached, but my link headers are context-sensitive links that display the login button if the user is not logged in, their username, if any, etc. . - not cached, while everything works.

The problem I encountered is that the title links belong to the wizard / layout page and are used throughout the board - regardless of whether the Action has the DonutOutputCache attribute set or not. When I create another action, let me call it β€œabout us,” without the donut cache attribute. I don't see the title link 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 link section is replaced with some XML comment.

My question in a nutshell: Is it possible for this library to reuse the same child action, regardless of whether the parent action uses cache cache or not?

Any help would be appreciated.

+4
source share
1 answer

Currently, you should use Html.Action along with the DonutOutputCache action filter to get a donut hole. If you use Html.Action without DonutOutputCache, you will see the placeholder comment you specified above.

This is supervision, although it will be considered in a future version.

see http://mvcdonutcaching.codeplex.com/workitem/2388

+4
source

Source: https://habr.com/ru/post/1385778/


All Articles