Cache Status

Cache Status

Viewing and Clearing Caches

  • Use the admin page /sitecore/admin/cache.aspx to view and clear caches 
  • Configure anonymous access on cache.aspx in IIS to make it viewable
  • Compare the cache Size to the MaxSize to determine if cache sizes are sufficient
  • Review the following caches: - Web[data] - Web[items] - Web[paths]

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Configuration.Settings.Caching
  • Sitecore.Configuration.Settings.Caching.StandardValues
  • Sitecore.Context
  • Sitecore.Data.Items.Item

Cache Status C# Web Control Code

Sitecore.Data.Items.Item item = Sitecore.Context.Item;
if (item == null) return;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Real-time Output");
output.RenderEndTag();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
string displayName = Sitecore.StringUtil.GetString(item.DisplayName, item.Name);
//using : for colon and ? for question mark and   for space
output.Write("{0}: {1}", "Item", displayName);
output.RenderEndTag(); //P

string accessResultCacheSize = Sitecore.Configuration.Settings.Caching.AccessResultCacheSize.ToString();
string avgItemSize = Sitecore.Configuration.Settings.Caching.AverageItemSize.ToString();
string blobIDCacheSize = Sitecore.Configuration.Settings.Caching.BlobIDCacheSize.ToString();
string cacheViewState = Sitecore.Configuration.Settings.Caching.CacheViewState.ToString();
string cachingEnabled = Sitecore.Configuration.Settings.Caching.Enabled.ToString();
string defaultClientDataCacheSize = Sitecore.Configuration.Settings.Caching.DefaultClientDataCacheSize.ToString();
string defaultDataCacheSize = Sitecore.Configuration.Settings.Caching.DefaultDataCacheSize.ToString();
string defaultFilteredItemsCacheSize = Sitecore.Configuration.Settings.Caching.DefaultFilteredItemsCacheSize.ToString();
string defaultHTMLCacheSize = Sitecore.Configuration.Settings.Caching.DefaultHtmlCacheSize.ToString();
string defaultItemCacheSize = Sitecore.Configuration.Settings.Caching.DefaultItemCacheSize.ToString();
string defaultPathCacheSize = Sitecore.Configuration.Settings.Caching.DefaultPathCacheSize.ToString();
string defaultPriority = Sitecore.Configuration.Settings.Caching.DefaultPriority.ToString();
string defaultPropertyCacheSize = Sitecore.Configuration.Settings.Caching.DefaultPropertyCacheSize.ToString();
string defaultProxyCacheSize = Sitecore.Configuration.Settings.Caching.DefaultProxyCacheSize.ToString();
string defaultRegistryCacheSize = Sitecore.Configuration.Settings.Caching.DefaultRegistryCacheSize.ToString();
string defaultTemplateCacheSize = Sitecore.Configuration.Settings.Caching.DefaultTemplateCacheSize.ToString();
string defaultViewStateCacheSize = Sitecore.Configuration.Settings.Caching.DefaultViewStateCacheSize.ToString();
string defaultXslCacheSize = Sitecore.Configuration.Settings.Caching.DefaultXslCacheSize.ToString();
string htmlLifetime = Sitecore.Configuration.Settings.Caching.HtmlLifetime.ToString();
string hugeCacheSize = Sitecore.Configuration.Settings.Caching.HugeCacheSize.ToString();
string isUserInRoleCacheSize = Sitecore.Configuration.Settings.Caching.IsUserInRoleCacheSize.ToString();
string itemCachingEnabled = Sitecore.Configuration.Settings.Caching.ItemCachingEnabled.ToString();
string largeCacheSize = Sitecore.Configuration.Settings.Caching.LargeCacheSize.ToString();
string loadFactor = Sitecore.Configuration.Settings.Caching.LoadFactor.ToString();
string maxLoadFactor = Sitecore.Configuration.Settings.Caching.MaxLoadFactor.ToString();
string mediumCacheSize = Sitecore.Configuration.Settings.Caching.MediumCacheSize.ToString();
string scavengeInterval = Sitecore.Configuration.Settings.Caching.ScavengeInterval.ToString();
string smallCacheSize = Sitecore.Configuration.Settings.Caching.SmallCacheSize.ToString();
string svDefaultCacheSize = Sitecore.Configuration.Settings.Caching.StandardValues.DefaultCacheSize.ToString();
string svAverageValueSize = Sitecore.Configuration.Settings.Caching.StandardValues.AverageValueSize.ToString();
string tinyCacheSize = Sitecore.Configuration.Settings.Caching.TinyCacheSize.ToString();
string userProfileCacheSize = Sitecore.Configuration.Settings.Caching.UserProfileCacheSize.ToString();

//using : for colon and ? for question mark and   for space
output.Write("{0}&#58;&#160;{1}", "Access Result Cache Size", "<b>" + accessResultCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Average Item Size", "<b>" + avgItemSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Blob ID Cache Size", "<b>" + blobIDCacheSize + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Caching Enabled", "<b>" + cachingEnabled + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Client Data Cache Size", "<b>" + defaultClientDataCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Data Cache Size", "<b>" + defaultDataCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Filtered Items Cache Size", "<b>" + defaultFilteredItemsCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default HTML Cache Size", "<b>" + defaultHTMLCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Item Cache Size", "<b>" + defaultItemCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Path Cache Size", "<b>" + defaultPathCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Client Data Cache Size", "<b>" + defaultClientDataCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Priority", "<b>" + defaultPriority + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Property Cache Size", "<b>" + defaultPropertyCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Proxy Cache Size", "<b>" + defaultProxyCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Template Cache Size", "<b>" + defaultTemplateCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default ViewState Cache Size", "<b>" + defaultViewStateCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default XSL Cache Size", "<b>" + defaultXslCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "HTML Lifetime", "<b>" + htmlLifetime + "</b><br/>");  
output.Write("{0}&#58;&#160;{1}", "Huge Cache Size", "<b>" + hugeCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Is User In Role Cache Size", "<b>" + isUserInRoleCacheSize + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Item Caching Enabled", "<b>" + itemCachingEnabled + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Large Cache Size", "<b>" + largeCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Load Factor", "<b>" + loadFactor + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Maximum Load Factor", "<b>" + maxLoadFactor + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Medium Cache Size", "<b>" + mediumCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Scavenge Interval", "<b>" + scavengeInterval + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Small Cache Size", "<b>" + smallCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Standard Values Default Cache Size", "<b>" + svDefaultCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Standard Values Cache Average Value Size", "<b>" + svAverageValueSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Tiny Cache Size", "<b>" + tinyCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "User Profile Cache Size", "<b>" + userProfileCacheSize + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "ViewState Cache Enabled", "<b>" + cacheViewState + "</b>");

output.RenderEndTag(); //Div