ASP.NET caching my page how do i measure how well it works?
Im getting to where i need to consider caching for my web application. Im a bit courious as to how long time 开发者_如何学Pythoni should cache the items, so i would like to make some sorts of statistics on how often i use my cache vs how often i load data from my server. How to go about doing this? Should i do this manually with data caching, like this:
- Does the data exist in my cache
- No - load it into cache and return it
- Insert a row into my database for statistics
- Yes - use the data from the cache
- Insert a row into my database for statistics
To me it seems a bit odd to query the cache and then insert into my database, seems the performance gain is lost then - right? What to do then?
Instead of looking at this problem as a sitewide problem, I would investigate those areas that are bottlenecks in your system, and consider caching those. The time you cache will depend on the data, and how frequently it changes.
Asp.net has some built in performance tools that will show you quite a bit of information about your cache
http://msdn.microsoft.com/en-us/library/ms972959.aspx
Don't focus on the cache hits vs. misses. Start off by focusing on the data that is retrieved often, but changes very little.
This article has some good information on implementing a caching policy
http://www.c-sharpcorner.com/UploadFile/vishnuprasad2005/ImplementingCachinginASP.NET11302005072210AM/ImplementingCachinginASP.NET.aspx
I would agree with Aaron. Why do you want to introduce caching? What problem are you trying to resolve? Are you having performance problems and are they directly related to database reads?
I have implemented ASP.Net/SQL caching on numerous projects and have found that the bottlenecks usually lie elsewhere i.e. page size.
I hope this helps.
B
精彩评论