More in this section

Forums / Developing with Sitefinity / Page publishing / caching

Page publishing / caching

2 posts, 0 answered
  1. Alvaro
    Alvaro avatar
    2 posts
    Registered:
    22 Sep 2009
    09 Jan 2010
    Link to this post
    Hiya,

    I have been building a custom menu control for Sitefinity CMS 3.7 SP2 which involves looking at three levels of pages within the Sitefinity tree structure. Because of this, there are multiple calls to the CmsManager.GetPages(Guid ParentId) made every time a page is loaded without any caching.

    One of the options I'd like to look at is the ability to cache the content that the custom menu control produces, but I'm trying to figure out a method to manage the cache so it's cleared when any page in the CMS is published.

    I understand that all pages can be managed by the ASP.NET cache individually, so when a page is published, the cache for that page is cleared, but is there a way of globally pick up when any page, rather than a specific page, is published to the site?

    The idea behind this functionality is that the user control can pick up on this event and re-build itself with any new content that may have been put live.

    Any thoughts or ideas welcome.

    Regards,
    Alvaro
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Jan 2010
    Link to this post
    Hello Alvaro Mari-Thompson,

    Make sure that your control implement ICacheableObject interface and has the following sample code


    #region ICacheableObject Members
     
        public System.Web.Caching.CacheDependency[] GetDependencies()
        {
            CmsSiteMapProvider provider = null;
            if (!String.IsNullOrEmpty(this.SiteMapDataSource1.SiteMapProvider))
                provider = SiteMap.Providers[this.SiteMapDataSource1.SiteMapProvider] as CmsSiteMapProvider;
            else
                provider = SiteMap.Provider as CmsSiteMapProvider;
            if (provider != null)
            {
                return new System.Web.Caching.CacheDependency[]{ provider.CloneCacheDependency()};
            }
            return null;
        }
     
        #endregion

    You have to return CacheDependency as shown in the code above.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered