How to avoid caching user control in asp.net mvc?

I add cache to my application, I have a page containing several user controls, my problem is that I just want to cache the data returned from the controller, but I do not want to cache the entire contents of the page. Since one of my user controls is an input control, if I cache the whole result then it will behave incorrectly.
my problem:
1. Is it possible to simply cache the data returned from the controller?
2. If the page is cached, can I force the control on the page to be blocked?

+3
source share
2 answers

I assume that caching means output caching (caching only the output html returned after processing the result of the controller view). What you are looking for is called cache replacement or β€œdonut caching”. As far as I know, it is not supported in ASP.NET MVC 1 and 2. In rc MVC 3 it is supported, as you can read here - http://weblogs.asp.net/scottgu/archive/2010/11/09/announcing- the-asp-net-mvc-3-release-candidate.aspx .

+3
source

If you want to cache data, you could use the controller in the session and give it out for viewing from the session when necessary, or get it fresh (and use it in the session) when you need to update the data.

0

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


All Articles