Optimization tip: Are your menus and controls cache efficient?

If you are struggling with your apllication consuming too much memory, it may be caused by your menus overusing the cache. Read further to see what you can do about it.
Hi there,

Recently, we have been solving few clients issues regarding their applications consuming too much memory. What was the reason was they didn't properly set up their controls, specifically menus.

In current version the controls usually cache their data using the combination of Current user name (due to security) + current culture + URL + ClientID of the control + some other parameters that may influence the results.

So basically by default each control caches the data per page and if you go to another page, it uses different data. It is like that because in different scenarios you can have the controls parameters based on different factors, so it may vary page from page.

This is not something that would mind for repeater or datalist, because they usually display unique content per each page (listing on parent and detail on child) but the menus display usually the same content on each of the pages, specifically the main menu on master page.

So basically if you do not set your own cache item name, the menu is caching the same data over and over for each page separately which results in high memory consumption, especially in case your documents contain large amounts of data in editable regions from Page tab.

What you should do in case you know your menu doesn't change with each page is to set its property Cache item name to some specific static unique value, that would ensure that the same cache item is used for such menu on all pages.

In general, you should always review your project and whereever the controls result in displaying the same data, ensure them shared Cache item name.

Good news is that we have done great job in 5.0 in menu optimization so it will be smarter and pull less data from database (limiting only to what is really needed) even when you do not set the cache item name explicitly.

Share this article on   LinkedIn

Martin Hejtmanek

Hi, I am the CTO of Kentico and I will be constantly providing you the information about current development process and other interesting technical things you might want to know about Kentico.


Martin Hejtmanek commented on

Hi Neil,

Yes, there are actually two ways I would recommend:

1) Go to the SiteManager -> System -> Cache -> Cache items and see if there aren't too many similar cache items (you sort of need to guess which ones are duplicit and which are not, there is no general rule you could use for this). There are better cache debugging options in version 5.0 so it will be easier in future.

You can also enable cache debugging and see particular cache accesses that the pages are using. See http://devnet.kentico.com/Blogs/Martin-Hejtmanek/October-2009/Webinar-2---Performance-optimization-and-caching-i.aspx for details.

2) Get a memory dump from your application and check what consumes the most of the memory, according these debugging labs:


If you find a lot of same-sized objects rooted from CacheEntry (where you can find also particular cache key), the cache is very probably overused.

I recommend you to first review all your menus, this is the location where most of the possible issues may be found.

Neil Ulrich commented on

On very large sites, is there a way to indentify potential cache items to possibly isolate them for use in the optimization tip described? Our site (KenticoCMS 4.0.3436) is using 500-800mb ram average on each of 3 servers in a webfarm. Recently, we have seen a slowness impacting performance. We would like to isolate what caused this. The Kentico logs and the IIS logs appear to be normal.