在asp.net mvc中“几乎静态”页面的输出缓存。

时间:2022-07-10 03:16:01

Most of the web applications have pages that are "almost static" in the sense they change really very rarely their content, but when it changes this should be seen immediately on the page.

大多数web应用程序的页面“几乎是静态的”,因为它们很少更改内容,但是当它更改时,应该立即在页面上看到。

So if you have some OutputCache attribute that permits to cache forever on your PageShow method, the cache should be invalidated immediately by a call to the PageUpdate method.

因此,如果您有一些OutputCache属性允许在PageShow方法上永久缓存,那么应该通过调用PageUpdate方法立即使缓存失效。

Sometimes the data of the page is almost identical but a small part (like the username). Here I have the possibility to render the whole page calling different render partials or just move the cache part outside the controller to reduce the most expensive calls in the db for getting the data (ie: cache on the service-repository layer).

有时页面的数据几乎是相同的,但只是很小的一部分(比如用户名)。在这里,我可以呈现整个页面调用不同的呈现部分,或者将缓存部分移到控制器之外,以减少在db中获取数据的最昂贵调用(即:服务存储库层上的缓存)。

Is there a pattern to do both types of caching effectively on asp.net mvc?

有没有一种模式可以在asp.net mvc上有效地执行这两种缓存?

1 个解决方案

#1


2  

What you've suggested is a common scenario - especially with user names.

您所建议的是一个常见的场景——特别是使用用户名。

What this is called is donut caching and is a very kewl feature.

这被称为甜甜圈缓存,是一个非常关键的特性。

Here's a helpful * question on the same topic .. which bounces you to this blog post (probably the most helpful link on this topic with regards to ASP.NET MVC).

这是关于同一主题的一个有用的*问题。它会让你跳转到这个博客文章(可能是这个话题中关于ASP的最有帮助的链接)。净MVC)。


A quick google search for this comes up with a number of helpful pages.

快速搜索谷歌会得到许多有用的页面。

HTH!

HTH !

#1


2  

What you've suggested is a common scenario - especially with user names.

您所建议的是一个常见的场景——特别是使用用户名。

What this is called is donut caching and is a very kewl feature.

这被称为甜甜圈缓存,是一个非常关键的特性。

Here's a helpful * question on the same topic .. which bounces you to this blog post (probably the most helpful link on this topic with regards to ASP.NET MVC).

这是关于同一主题的一个有用的*问题。它会让你跳转到这个博客文章(可能是这个话题中关于ASP的最有帮助的链接)。净MVC)。


A quick google search for this comes up with a number of helpful pages.

快速搜索谷歌会得到许多有用的页面。

HTH!

HTH !