ASP.NET MVC displays output for each action

We use a fairly large site with ASP.NET MVC 3 and AppFabric as distributed caching. We have implemented a custom OutputCacheAdapter to use our AppFabric cluster.

We see that ASP.NET calls the OutputCacheProvider.Get () method for each action, even if this action is NOT adorned with the @OutputCacheAttribute attribute.

This is not a big problem if you use the default outputcacheprovider output file, but this is when you run outputcacheprovider, which is located on separate machines.

+6
source share
2 answers

By design, the output cache is first checked for a cached copy of the page. If there is a cached copy, it is returned and nothing else is executed. In particular, no controller and no controller action is performed, checked, or performed. This only happens if the page is not cached.

You will need to change the cache provider so that it can quickly determine if the page can be potentially cached. Only if this is a cachable page, then it should go and check the distributed cache. This check cannot be based on OutputCacheAttribute because they are not available during this part of the request processing. Instead, quickly check the URL, cookies, and other HTML header information.

+4
source

You can use the outputcache attribute Donut Cache, which allows you to define a prefix for the cache output keys. Therefore, in your user provider, simply enter / set the cache if the cache key starts with your own prefix.

0
source

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


All Articles