我如何使用缓存提高ASP.NET MVC 3网站性能? [英] How i can improve ASP.NET MVC 3 website performance by using Cache?

查看:40
本文介绍了我如何使用缓存提高ASP.NET MVC 3网站性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,例如twitter,每30秒或更短的时间就会更新一次.网站首页分为三个部分:-

I have a Website something like twitter who are update per 30 seconds or less. the website frontpage have three part:-

左侧面板或右侧部分很少更新,但是右侧部分有随机更改,因此我不需要缓存它们,但是左侧或右侧的所有内容都需要缓存以提高性能.

the leftside panel or right side part rarely to be updated but a section on rightside have random changes so i not need to cache them but everything in leftside or rightside i need to be in cache to improve performance.

列出一些新事物时,中间的栏每隔几秒钟就会发生变化.所以我认为,如果我缓存它们,那么用户将永远不会得到更新,

the middle bar have changes in every few second when some new thing come to listed. so i thing that if i cache them then the user never get update so

当数据库中发生更改时,我如何使用缓存并删除所有缓存.在ASP.NET MVC中做到这一点的任何技巧

how i can use cache and remove all cache when changes happend in database. any trick to do that in ASP.NET MVC

我要做一个普通事情的整个问题:-

the whole question i have for doing a common thing that :-

如果我使用缓存,那么用户永远不会在网站更新后立即获得更新,因此,每当数据库发生新情况时,我都需要销毁缓存.所以我怎么能在asp.net mvc中做到这一点

if i use cache then user never got update soon as website have so i need to destroy cache whenever new thing goes happened in databse. so how i can do this in asp.net mvc

推荐答案

您需要使用

You need to use the OutputCacheAttribute or something similar. This action filter "represents an attribute that is used to mark an action method whose output will be cached." When an action updates the database, the resulting view should be cached, because it is overwriting the previously cached data.

这篇关于我如何使用缓存提高ASP.NET MVC 3网站性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆