More in this section
Forums / Developing with Sitefinity / Defaulting Enable Cache to true and cache expiration value

Defaulting Enable Cache to true and cache expiration value

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Krister
    Krister avatar
    1 posts
    12 Jan 2006
    26 Jun 2009
    Link to this post
    Is there a way to customize the default for every page to default the cache parameter to True?

    Is there a way to change the default cache duration setting from 120 seconds to some larger value?

    Is there a way to make these settings for multiple pages at one time? (after doing this manually for about 75 pages, I'm thinking I probably should have waited to see the answer to this question)  If there's an answer, then it will save me the time of doing it manually for the remaining 100 pages, though :)

  2. Vlad
    Vlad avatar
    498 posts
    19 Jun 2017
    26 Jun 2009
    Link to this post
    Hello Krister,

    You can control the global values (duration and sliding expiration) for page caching in telerik/framework/caching section in the the web.config:
        <caching defaultProvider="memoryCache"
            <add name="memoryCache" type="Telerik.Caching.MemoryCachingProvider, Telerik.Framework"/> 
            <add name="ASPNET" type="Telerik.Caching.AspNetCachingProvider, Telerik.Framework"  
            duration="120" slidingExpiration="true"/> 
          <cacheDependency mode="InMemory"/> 

    But there is no a global value for applying Enable Caching for all pages. You should do it with the user interface.
    Or, you can write a code, which uses the API to iterate through the pages and enables caching for each page, i.e.:
                // This code will enable caching for each page in the WebSite 
                Telerik.Cms.CmsManager manager = new Telerik.Cms.CmsManager(); 
                foreach (Telerik.Cms.ICmsPage page in manager.GetPages()) 
                    Telerik.Cms.ICmsPage pageForEdit = manager.GetPage(page.ID, trueas Telerik.Cms.ICmsPage; 
                    if (pageForEdit != null 
                        && (pageForEdit.PageType == Telerik.Cms.CmsPageType.Normal)) 
                        pageForEdit.RequireCaching = true

    The above is related to the existing pages in the site.
    However, you can customize the default values of some page properties, so the newly created pages will use your default values. In, order to do this, you should declare telerik/cms/pages/defaultProperties element in the web.config:
    <cms defaultProvider="Sitefinity" ...> 
        <defaultProperties requireCaching="true" navigable="true" disableViewState="false" requireSSL="false" /> 

    Where, you can see the page properties, which default values you can customize. All except the requireCaching attribute are set with their default values and you can skip them from the configuration.

    Hope this is helpful.

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered