项目介绍

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. mvc5 解析route源码实现自己的route系统

    Asp.net mvc5 解析route源码实现自己的route系统   url route 路由系统的责任是找到匹配的路由,创建路由数据,并将请求分配给一个处理程序. 选择动作是 MVC 的处理程序 ...

  2. Https 客户端与服务器交互过程梳理(转)

    本文试图以通俗易通的方式介绍Https的工作原理,不纠结具体的术语,不考证严格的流程.我相信弄懂了原理之后,到了具体操作和实现的时候,方向就不会错,然后条条大路通罗马.阅读文本需要提前大致了解对称加密 ...

  3. zzu--2014年11月16日月潭赛 C称号

    1230: Magnets Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 24  Solved: 13 [id=1230" style=&q ...

  4. RAC下一个Fatal NI connect error 12170.错误处理

    原创作品,离 "深蓝blog" 博客,欢迎转载,请务必注明转载的来源.否则有权追究版权责任. 深蓝的blog:http://blog.csdn.net/huangyanlong/a ...

  5. atcoder 它February 29th

    Time limit : 2sec / Stack limit : 256MB / Memory limit : 256MB Problem Charlie was born January 1st ...

  6. java Map 之 排序(key,value)

    一:起因: (1)现实中须要Map容器进行排序的情况非常多非常多:由于Map<key,value>键值对的存储结构特别是HashMap的结构是非常优秀的,数据存储就难免对其进行排序: (2 ...

  7. C++语言债券系列之十一——友元函数和拷贝构造函数

    1.好友功能 (1)友元函数类的普通功能外定义. 定义友元函数和相同的正常功能.在类必须声明的正常功能为好友. (2)友元函数不是一个成员函数. 你不能反对打电话.但直接调用:友元函数访问类的公共.p ...

  8. ASP.NET MVC+EF框架+EasyUI实现权限管理系列(4)-业务逻辑层的封装

    原文:ASP.NET MVC+EF框架+EasyUI实现权限管理系列(4)-业务逻辑层的封装 ASP.NET MVC+EF框架+EasyUI实现权限管系列 (开篇)   (1):框架搭建    (2) ...

  9. windows下系统移植到linux下出现的问题

    今天遇到了一个之前没有遇到的问题,记录一下. 我们是在windows下进行开发的,最终系统是部署在linux服务器上. 在windows一切正常,但是部署到linux下时,有些功能不能用了.通过log ...

  10. 【C++基础】类的组合

    所谓类的组合是指:类中的成员数据是还有一个类的对象或者是还有一个类的指针或引用.通过类的组合能够在已有的抽象的基础上实现更复杂的抽象. 比如: 1.按值组合 #include<iostream. ...