惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - Yok

js动态代理 Hammett joined Microsoft 鼻炎无端端好了 罚抄100遍 Castle Team宣布Castle将与ASP.NET MVC整合 邪恶的webform MonoRail FAQ MonoRail资源汇总 招.net and/or javascript程序员(广州) javascript版贪食蛇 Castle 1.0 rc2发布 招聘.net程序员(广州) javascript reference card 招聘.net程序员(广州) Ready To Rock 做了一回二五仔 - BEA广州User Group活动见闻 MonoRail - 生命周期及controller/action/view详解 MonoRail - 前期准备 MonoRail - 简介
实现MonoRail页面缓存
Yok · 2007-01-23 · via 博客园 - Yok

monorail是一个mvc模式的web框架, 它完全抛弃了传统的webform. 很多朋友都担心monorail会存在性能问题. 一个原因是它大量使用反射, 一个是它的velocity页面模板是解释执行(monorail有编译执行的brail模板引擎, 但是通常由于学习成本及它未及velocity成熟的因没有被采用). 当然webform复杂的生命周期, 控件结构及viewstate机制也是性能的瓶颈. 经过简单的测试, 总体来说monorail会比webform慢5%左右.

我感觉到更大的问题是monorail的官方并不支持页面级缓存. 页面缓存对互联网应用来说是很重要的, 因为网站读操作的频率要远远大于写, 而且还会不幸碰上无耻的爬虫和发广告软件的攻击. 我反编译了跟缓存相关的.net framework代码后, 发现它和webform完全无关, 管理页面缓存的System.Web.Caching.OutputCacheModule在HttpApplication的ResolveRequestCache事件中寻找是否有可用的缓存, 在UpdateRequestCache事件中检查当前HttpResponse的CachePolicy, 决定是否要把Response的内容缓存起来. 所以任何形式的asp.net应用程序都可以使用它, 只需要设置好当前的HttpResponse的CachePolicy. 在webform里页面缓存是作为预编译指令标记在aspx里, 在monorail中, 典型的的做法就是为controller编写一个facility, 然后通过自定义的Attribute去指定缓存相关的属性.

这个facility很简单: 定义一个的Attribute用来标记在controller和action上, 属性照搬@outputcache指令的参数Duration, Location, VaryByParam, VaryByHeader, VaryByCustom, 注册自己的contributor, inspector, 在inspector里根据Attribute的属性去设置HttpContext.Current.Response.Cache, 就这样ok了...

[PageCache]
public class HomeController : SmartDispatcherController
{
    [PageCache(Duration
= 30, VaryByParam = "*")]
    
public virtual void Index()
    {
    }
}

https://files.cnblogs.com/Yok/MonoRailPageCache.rar