title: How to determine the size in bytes of the ASP.NET Cache?
body: <p>I'm in active development of an ASP.NET web application that is using server side caching and I'm trying to understand how I can monitor the size this cache during some scale testing.  The cache stores XML documents of various sizes, some of which are multi-megabyte.</p>
  
  <p>On the <a href="http://msdn.microsoft.com/en-us/library/system.web.caching.cache.aspx" rel="nofollow noreferrer">System.Web.Caching.Cache</a> object of <a href="http://msdn.microsoft.com/en-us/library/system.web.caching.aspx" rel="nofollow noreferrer">System.Web.Caching</a> namespace I see various properties, including <a href="http://msdn.microsoft.com/en-us/library/system.web.caching.cache.count.aspx" rel="nofollow noreferrer">Count</a>, which gets "the number of items stored in the cache" and <a href="http://msdn.microsoft.com/en-us/library/system.web.caching.cache.effectiveprivatebyteslimit.aspx" rel="nofollow noreferrer">EffectivePrivateBytesLimit</a>, which gets "the number of bytes available for the cache."  Nothing tells me the size in bytes of the cache.</p>
  
  <p>In the <a href="http://msdn.microsoft.com/en-us/library/ms978500.aspx" rel="nofollow noreferrer">Understanding Caching Technologies</a> section of the "Caching Architecture Guide for .NET Framework Applications" guide, there is a "Managing the Cache Object" section with a table (Table 2.2: Application performance counters for monitoring a cache) listing a set of application performance counters, but I don't see any that give me the current size of the cache.</p>
  
  <p>What is a good way to find the size this cache?  Do I have to set a byte limit on the cache and look at one of the turnover rates?  Am I thinking of this problem in the wrong way?  Is the answer to <a href="https://stackoverflow.com/questions/344210/how-to-determine-total-size-of-asp-net-cache">How to determine total size of ASP.Net cache</a> really the best way to go?</p>