Dynamic Content Inside Cache Tag Helper - Donut Hole Caching

259 views Asked by At

I believe what I want to do used to be referred to as Donut Hole Caching. I'm not sure how to implement it in .NET Core MVC though. Essentially I have a large page, with static content by query string, except for a small part that needs to remain dynamic. What I want can be summarized as:

<body>  
   <cache vary-by-query="...">
   @foreach(var item in Model)
   {
       <div class="lots-of-static-content"> 

           <cache enabled="false">
               <div class="dynamic-content>
               </div>
           </cache>

       </div>
   } 

   </cache>
</body>

I want to cache everything except the dynamic content. Obviously, this isn't working - the dynamic content is still cached. I'm sure this is a common problem, but I'm not sure what the correct way to approach it is, if anyone can offer some assistance.

1

There are 1 answers

0
KevDevMan On

You will find Donut caching with source code here.

https://github.com/moonpyk/mvcdonutcaching

You should find all the patterns and functionality you will need to achieve what you want. But you will need to translate them to .Net Core.