项目介绍

ASP.NET MVC Extensible Donut Caching brings donut caching to ASP.NET MVC 3 and later. The code allows you to cache all of your page apart from one or more Html.Actions which can be executed every request. Perfect for user specific content.

项目地址:https://github.com/moonpyk/mvcdonutcaching

Download

The best way to add donut caching to your MVC project is to use the NuGet package. From within Visual Studio, select Tools | Library Package Manager and then choose either Package Manager Console or Manage NuGet Packages. Via the console, just type install-package MvcDonutCaching and hit return. From the GUI, just search for MvcDonutCaching and click the install button.

Usage

The package adds several overloads to the built-in Html.Action HTML helper. The extra parameter in each overload is named excludeFromParentCache. Set this to true for any action that should not be cached, or should have a different cache duration from the rest of the page.

@Html.Action("Login", "Account", true)

The package also include a DonutOutputCacheAttribute to be used in place of the built-in OutputCacheAttribute. This attribute is typically placed on every controller action that needs be be cached.

You can either specify a fixed duration:

[DonutOutputCache(Duration = "")]
public ActionResult Index()
{
return View();
}

Or, use a cache profile:

[DonutOutputCache(CacheProfile = "FiveMins")]
public ActionResult Index()
{
return View();
}

If you are using cache profiles, be sure to configure the profiles in the web.config. Add the following within the system.web element:

<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="FiveMins" duration="300" varyByParam="*" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>

You can also configure the output cache to use a custom provider:

<caching>
<outputCache defaultProvider="DistributedCacheProvider">
<providers>
<add name="DistributedCacheProvider" type="DevTrends.Example.DistributedCacheProvider" />
</providers>
</outputCache>
</caching>

Note, that a custom provider is not included with this project but you can write one fairly easily by subclassingSystem.Web.Caching.OutputCacheProvider. A number of implementations are also available on the web.

More Information

A comprehensive guide to MVC Extensible Donut Caching is now available on the DevTrends Blog.

谢谢浏览!

ASP.NET MVC 缓存扩展 - Donut Caching的更多相关文章

  1. Asp.Net MVC 缓存设计

    Asp.Net MVC 缓存: 1. 可以直接在Controller,Action上面定义输出缓存OutputCache,如下,第一次请求这个Index的时候,里面的代码会执行,并且结果会被缓存起来, ...

  2. ASP.NET MVC缓存使用

    局部缓存(Partial Page) 1.新建局部缓存控制器: public class PartialCacheController : Controller { // GET: /PartialC ...

  3. ASP.NET MVC 缓存使用示例

    应该说,缓存的设计是一门较为复杂的学问,主要考虑的问题包括:要不要缓存?要缓存哪些数据?要缓存多少数据?要缓存多久?如何更新缓存(手动还是自 动)?将缓存放在哪里?本文将以较为通俗易懂的方式,来看一看 ...

  4. ASP.NET MVC:缓存功能的设计及问题

    这是非常详尽的asp.net mvc中的outputcache 的使用文章. [原文:陈希章 http://www.cnblogs.com/chenxizhang/archive/2011/12/14 ...

  5. ASP.NET MVC缓存

    根据缓存的位置不同,可以区分为: ①客户端缓存(缓存在用户的客户端,例如浏览器中) ②服务器缓存(缓存在服务器中,可以缓存在内存中,也可以缓存在文件里,并且还可以进一步地区分为本地缓存和分布式缓存两种 ...

  6. 扩展 ASP.NET MVC 模型扩展 – ASP.NET MVC 4 系列

           大部分人不能将核心运行时(System.Web 中的类)和 ASP.NET Web Forms 应用程序平台(System.Web.UI 中的类)区分开来.        ASP.NET ...

  7. ASP .NET MVC HtmlHelper扩展——简化“列表控件”的绑定

    在众多表单元素中,有一类<select>元素用于绑定一组预定义列表.传统的ASP.NET Web Form中,它对应着一组重要的控件类型,即ListControl,我们经常用到DropDo ...

  8. 13个 ASP.NET MVC 的扩展

    ASP.NET MVC设计的主要原则之一是可扩展性.处理管线(processing pipeline)上的所有(或大多数)东西都是可替换的.因此,如果您不喜欢ASP.NET MVC所使用的约定(或缺乏 ...

  9. 【asp.net mvc】 扩展 htmlhelper 实现分页

    参考文档:http://www.cnblogs.com/caofangsheng/p/5670071.html                  http://www.cnblogs.com/arte ...

随机推荐

  1. java多线程学习(一)

    一.操作系统线程和进程的概念 线程是指进程中的一个运行单元,这个过程中也可调度实体. 线程与进程的差别: (1)地址空间:线程为进程内的一个运行单元.进程至少有一个线程(进程的主线程):进程的全部线程 ...

  2. oracle_连接数_查看

    查看oracle数据库的连接数以及用户   .查询oracle的连接数 select count(*) from v$session; .查询oracle的并发连接数 select count(*) ...

  3. ASP.NET 5 (vNext)

    ASP.NET 5 (vNext) 理解和入门   概述 ASP.NET 5 (又称为vNext) 是自ASP.NET产生15年以来一次革命性的更新, 我们可以从以下几点来理解其概貌和意义: ASP. ...

  4. MVC 插件化框架支持原生MVC的Area和路由特性

    .NET MVC 插件化框架支持原生MVC的Area和路由特性 前面开放的源码只是简单的Plugin的实现,支持了插件的热插拔,最近晚上偶然想到,原生的MVC提供Areas和RouteAtrribut ...

  5. passenger安装nginx

    1.更换淘宝gem gem sources --remove https://rubygems.org/ gem sources -a https://ruby.taobao.org/ 2.gem安装 ...

  6. 关于webbrowser控件自动登陆的问题

    原文:关于webbrowser控件自动登陆的问题 楼主dtb(陈少)2004-03-04 22:16:55 在 VB / 网络编程 提问 请问怎么用webbrowser自动登陆www.jp168.co ...

  7. PHP添加Mssql/sqlserver2000扩展,适用于Php5.2/Php5.3/Php5.4

    原文:PHP添加Mssql/sqlserver2000扩展,适用于Php5.2/Php5.3/Php5.4 本文介绍如何在Windows下配置php扩展. 本文链接 http://blog.csdn. ...

  8. SSH深度历险记(两) Jboss+EJB一审

    学习感悟:每次学习新知识.通过初审会从小事做起,获得成就感.经典Hello Workd我们成功的例子奠定了门哈,呢.非常好的理解了.Ejb的核心. 今天主要以这个小实例,来学习EJB的分布式,我们能够 ...

  9. 在asp.net webservice中如何使用session

    原文:在asp.net webservice中如何使用session 原文:刘武|在asp.net webservice中如何使用session 在使用asp.net编写webservice时,默认情 ...

  10. 第3章3节《MonkeyRunner源码剖析》脚本编写示例: MonkeyImage API使用示例(原创)

    天地会珠海分舵注:本来这一系列是准备出一本书的,详情请见早前博文“寻求合作伙伴编写<深入理解 MonkeyRunner>书籍“.但因为诸多原因,没有如愿.所以这里把草稿分享出来,所以错误在 ...