ASP.NET MVC 缓存扩展 - Donut Caching
项目介绍
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的更多相关文章
- Asp.Net MVC 缓存设计
Asp.Net MVC 缓存: 1. 可以直接在Controller,Action上面定义输出缓存OutputCache,如下,第一次请求这个Index的时候,里面的代码会执行,并且结果会被缓存起来, ...
- ASP.NET MVC缓存使用
局部缓存(Partial Page) 1.新建局部缓存控制器: public class PartialCacheController : Controller { // GET: /PartialC ...
- ASP.NET MVC 缓存使用示例
应该说,缓存的设计是一门较为复杂的学问,主要考虑的问题包括:要不要缓存?要缓存哪些数据?要缓存多少数据?要缓存多久?如何更新缓存(手动还是自 动)?将缓存放在哪里?本文将以较为通俗易懂的方式,来看一看 ...
- ASP.NET MVC:缓存功能的设计及问题
这是非常详尽的asp.net mvc中的outputcache 的使用文章. [原文:陈希章 http://www.cnblogs.com/chenxizhang/archive/2011/12/14 ...
- ASP.NET MVC缓存
根据缓存的位置不同,可以区分为: ①客户端缓存(缓存在用户的客户端,例如浏览器中) ②服务器缓存(缓存在服务器中,可以缓存在内存中,也可以缓存在文件里,并且还可以进一步地区分为本地缓存和分布式缓存两种 ...
- 扩展 ASP.NET MVC 模型扩展 – ASP.NET MVC 4 系列
大部分人不能将核心运行时(System.Web 中的类)和 ASP.NET Web Forms 应用程序平台(System.Web.UI 中的类)区分开来. ASP.NET ...
- ASP .NET MVC HtmlHelper扩展——简化“列表控件”的绑定
在众多表单元素中,有一类<select>元素用于绑定一组预定义列表.传统的ASP.NET Web Form中,它对应着一组重要的控件类型,即ListControl,我们经常用到DropDo ...
- 13个 ASP.NET MVC 的扩展
ASP.NET MVC设计的主要原则之一是可扩展性.处理管线(processing pipeline)上的所有(或大多数)东西都是可替换的.因此,如果您不喜欢ASP.NET MVC所使用的约定(或缺乏 ...
- 【asp.net mvc】 扩展 htmlhelper 实现分页
参考文档:http://www.cnblogs.com/caofangsheng/p/5670071.html http://www.cnblogs.com/arte ...
随机推荐
- JAVA解决大数
主题链接:CLICK HERE~ 有了Java求解大数变得如此简单,以后再也不用操心大数模板了.哦啦啦啦. import java.math.BigInteger; import java.math. ...
- Scrapy研究和探索(五岁以下儿童)——爬行自己主动多页(抢别人博客所有文章)
首先.在教程(二)(http://blog.csdn.net/u012150179/article/details/32911511)中,研究的是爬取单个网页的方法.在教程(三)(http://blo ...
- JMeter怎么在get URL请求、POST请求中添加动态参数用于服务器段安全验证
从前一个页面(含有服务器段返回给客户端的参数,用于在下一次请求时验证)中添加后置处理器中的Regular Expression Extractor,使用正则表达式对参数进行提取. 在用到这些变量时可以 ...
- c++指针存储应用程序和释放内存的问题
C++中指针在new和delete操作的时候对内存堆都做了些什么呢.下面解: 1.指针的new操作: 指针在new之后,会在内存堆中分配一个空间.而指针中存放的是这个空间的地址.如: void mai ...
- 基于PHP的crontab定时任务管理
BY JENNER · 2014年11月10日· 阅读次数:6 linux的crontab一直是server运维.业务开展的利器.但当定时任务增多时,管理和迁移都变得非常麻烦,并且easy出问题.以下 ...
- 十天学Linux内核之第六天---调度和内核同步
原文:十天学Linux内核之第六天---调度和内核同步 心情大好,昨晚我们实验室老大和我们聊了好久,作为已经在实验室待了快两年的大三工科男来说,老师让我们不要成为那种技术狗,代码工,说多了都是泪啊,, ...
- ftp server来源分析20140602
ftp server学习位和源代码分析片 记录自己的第一个开源的分析过程: 从源代码:野狐灯(我接下来的几篇文章是从源头:野狐灯,每个以下哪项不是他们设置.) 20140602 Ftp的源码目录例如 ...
- Sharepoint 2013 左右"SPChange"一个简短的引论
于SharePoint于,我们经常需要获得这些更改项目,竟api为我们提供SPChange物.下列,在通过我们的目录资料这一目标. 1.创建测试列表,名字叫做"SPChangeItems&q ...
- Oracle免费的便捷Web应用开发框架
Oracle免费的便捷Web应用开发框架 APEX 总体来说,APEX是我见过最便捷最高效的开发框架,用起来比PHP还舒服.上手简单,学习成本极低,曾经有个做行政的小女生,在我指导下两天就可以开发出简 ...
- 采用tcpdump攫Android网络数据包
1 空灵的原理 tcpdump(需Root用户执行)拦截和显示发送或收到过网络连接到该机器的TCP/IP和其它数据包.简单说就监控手机进出网络数据. 2 方法优劣 2.1长处 1.手机数据包无遗漏 2 ...