简体   繁体   中英

How i can improve ASP.NET MVC 3 website performance by using Cache?

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

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 :-

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.

What you are looking for is SqlCacheDependency. See here .

You should be able to use partial views and mark the to be cached... Search google for caching partial views...

You could look at cache dependencies to flush the cache... or you could just have your cache expire in a given time period and it would eventually catch up to the live data...

it is hard to pick the best solution without understanding the problem fully but that should point you in the correct direction...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM