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

試著忘記壹切 提交于 2019-12-25 14:42:49

问题


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


回答1:


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.




回答2:


What you are looking for is SqlCacheDependency. See here.




回答3:


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



来源:https://stackoverflow.com/questions/5527746/how-i-can-improve-asp-net-mvc-3-website-performance-by-using-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!