For performance purposes, I need to cache the results of the homepage action, while allowing the display name of the logged-in user to remain uncached.
I used to achieve something similar on ASP.NET MVC Framework projects using DonutOutputCache. This system was very useful because you were able to put an entire action into the output cache while maintaining partial view results outside of the cache. I could thus have three or four partials who needed personalization—e.g., a survey, an analytic tag, the user name and avatar, a behavior based article list, etc.).
Do you know if I could handle this with ASP.NET Core's new [OutputCache]
attribute or <cache />
Tag Helper?
At the moment, I put the whole home page into a classic memory cache. It would be fantastic to have this kind of Tag Helper:
<cache expires-after="TimeSpan.FromMinutes(60)">
@*Cached part*@
<cache-hole>
@*Refreshed on each page refresh. This could work with a ResponseCache attribute too.*@
@await Components.InvokeAsync("UserProfile")
</cache-hole>
</cache>