Donut Caching in Kentico 12 MVC

Prashant Arora asked on April 26, 2021 19:25

I have implemented Donut Caching in my project MVC using standard DonutCaching nuget package MVCDonutCaching. Now, everything else is working fine except that when I try to login to admin portal and check any page in portal, and then view the same page in live site mode, then, the portal controls are getting displayed in my live site. Or vice versa, when I view the live site mode first, and then view the portal, then the live site is displayed on Portal page, means I cannot see the portal controls etc. Please help.

Recent Answers

Dmitry Bastron answered on April 27, 2021 13:05

Hi Prashant,

You'd need to adjust the behaviour of caching slightly. On before controller action executing by DonutCaching you need to check whether the request came from CMS admin or from the frontend:

var editMode = HttpContext.Kentico().PageBuilder().EditMode || HttpContext.Kentico().Preview().Enabled;

If it's coming from the edit mode, you need to disable donut caching. This will solve your issue.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.