Items Cache

Items Cache

Items Cache

  • A type of database cache that stores items
  • Assigned under a specific database in the web.config file
  • SetDBName in the path can be "web", "master", "core" or "filesystem"
  • <items> in the path specifies the Items cache size for the database

Items Cache Dependencies

  • Item caches are dependent on Data caches
  • When an Item cache does not contain an entry for a requested item, Sitecore retrieves the entry from the Data cache and stores the data in the Items cache

Enabling Item Caching

  • The Caching.ItemCachingEnabled setting in web.config enables item caching
  • This setting determines if caching of items should be enabled
  • Specify 'true' to enable item caching and 'false' to disable

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

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

Configuration Settings

Database Setting

    <database id="DBName" singleinstance="true" type="Sitecore.Data.Database, Sitecore.Kernel">
          <cachesizes hint="setting">

Default Setting


<setting name="Caching.ItemCachingEnabled" value="true"/>



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.Write("C# Web Control Real-time Output");

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
//using &#58; for colon and &#63; for question mark and &#160; for space
output.Write("{0}&#58;&#160;{1}", "Item", item.DisplayName);
output.RenderEndTag(); //P

string itemCachingEnabled = Sitecore.Configuration.Settings.Caching.ItemCachingEnabled.ToString();
string defaultItemCacheSize = Sitecore.Configuration.Settings.Caching.DefaultItemCacheSize.ToString();
string averageItemSize = Sitecore.Configuration.Settings.Caching.AverageItemSize.ToString();
string defaultFilteredItemsCacheSize = Sitecore.Configuration.Settings.Caching.DefaultFilteredItemsCacheSize.ToString();

//using &#58; for colon and &#160; for space
output.Write("{0}&#58;&#160;{1}", "Item Caching Enabled", "<b>" + itemCachingEnabled + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Item Cache Size", "<b>" + defaultItemCacheSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Average Item Size", "<b>" + averageItemSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Filtered Items Cache Size", "<b>" + defaultFilteredItemsCacheSize + "</b>");

output.RenderEndTag(); //Div

Items Cache C# Web Control Output

Item Caching Enabled: True
Default Item Cache Size: 10485760
Average Item Size: 5000
Default Filtered Items Cache Size: 2097152