Measuring ASP.NET and SharePoint output cache

During ASP.NET output caching week in my local blog I wrote about how to measure ASP.NET output cache. As my posting was based on real work and real-life results then I thought that this posting is maybe interesting to you too. So here you can read what I did, how I did and what was the result.


Caching is not effective without measuring it. As MVP Henn Sarv said in one of his sessions then you will get what you measure. And right he is. Lately I measured caching on local Microsoft community portal to make sure that our caching strategy is good enough in environment where this system lives. In this posting I will show you how to start measuring the cache of your web applications.

Although the application measured is built on SharePoint Server publishing infrastructure, all those counters have same meaning as similar counters under pure ASP.NET applications.

Measured counters

I used Performance Monitor and the following performance counters (their names are similar on ASP.NET and SharePoint WCMS):

  • Total number of objects added – how much objects were added to output cache.
  • Total object discards – how much objects were deleted from output cache.
  • Cache hit count – how many times requests were served by cache.
  • Cache hit ratio – percent of requests served from cache.

The first three counters are cumulative while last one is coefficient. You can use also other counters to measure the full effect of caching (memory, processor, disk I/O, network load etc before and after caching).

Measuring process

The measuring I describe here started from freshly restarted web server. I measured application during 12 hours that covered also time ranges when users are most active. The time range does not include late evening hours and night because there is nothing to measure during these hours.

During measuring we performed no maintenance or administrative tasks on server. All tasks performed were related to usual daily content management and content monitoring. Also we had no advertisement campaigns or other promotions running at same time.

The results

You can see the results on following graphic.

  Total number of objects added
  Total object discards
  Cache hit count
  Cache hit ratio

You can see that adds and discards are growing in same tempo. It is good because cache expires and not so popular items are not kept in memory. If there are more popular content then the these lines may have bigger distance between them.

Cache hit count grows faster and this shows that more and more content is served from cache. In current case it shows that cache is filled optimally and we can do even better if we tune caches more. The site contains also pages that are discarded when some subsite changes (page was added/modified/deleted) and one modification may affect about four or five pages. This may also decrease cache hit count because during day the site gets about 5-10 new pages.

Cache hit ratio is currently extremely good. The suggested minimum is about 85% but after some tuning and measuring I achieved 98.7% as a result. This is due to the fact that new pages are most often requested and after new pages are added the older ones are requested only sometimes. So they get discarded from cache and only some of these will return sometimes back to cache. Although this may also indicate the need for additional SEO work the result is very well in technical means.


Measuring ASP.NET output cache is not complex thing to do and you can start by measuring performance of cache as a start. Later you can move on and measure caching effect to other counters such as disk I/O, network, processors etc. What you have to achieve is optimal cache that is not full of items asked only couple of times per day (you can avoid this by not using too long cache durations). After some tuning you should be able to boost cache hit ratio up to at least 85%.

Liked this post? Empower your friends by sharing it!
Categories: ASP.NET SharePoint

View Comments (4)

  • Is Performance Monitor accurate when used on a VM? I mean, can the clock be relied upon?

  • Great Article !! I did not know that it is so easy to measure cache.

    Thanks for this.

    Nikunj Dhawan

  • This is great article yes!

    Will be nice to see how you cache items and use your cache on that particular App. That will allow us to compare and learn how to use cache as is best!

    thank you!

  • Thanks for feedback, Jean-Francois!

    It really depends on app you are working on. Different applications are built differently and they are also using their data differently. It is not possible to say that all caching done on one application fits well also to another. You have to measure your application, improve it and the measure it again until you achieve performance you need.

Related Post