1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Caching and Web Farms

Caching and Web Farms

6 posts, 0 answered
  1. Chris Dodge
    Chris Dodge avatar
    16 posts
    Registered:
    17 Dec 2009
    18 May 2010
    Link to this post
    Hello,

    We're going to be deploying Sitefinity into a load-balanced environment (2 servers). I understand there are some web.config settings to enable this.

    However, I'd like to get some understanding about how caching works across multiple machines. After an edit, is content immediately refreshed on all the servers in the web farm simultaneously?

    If not, is there a way programmatically to force each instance to refresh all in memory caches?

    Thanks,

    Chris
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 May 2010
    Link to this post
    Hi Chris Dodge,

    By default pages use ASPNET caching

    <cms defaultProvider="Sitefinity" pageExtension=".aspx" redirectToHomePage="false"  projectName="SampleProject"  disabled="false" pageEditorUIMode="Overlay">
                <providers>
                    <clear/>
                    <add connectionStringName="DefaultConnection" allowPageHistory="true"  allowPageWorkflow="False" cachingProviderName="ASPNET" name="Sitefinity" type="Telerik.Cms.Data.DefaultProvider, Telerik.Cms.Data"/>
                </providers>

    In caching section of the web.config you can set caching duration ( in seconds) and slidingExpiration.

    <caching defaultProvider="memoryCache">
        <providers>
            <add name="memoryCache" type="Telerik.Caching.MemoryCachingProvider, Telerik.Framework"/>
            <add name="ASPNET" type="Telerik.Caching.AspNetCachingProvider, Telerik.Framework" duration="120" slidingExpiration="true"/>
        </providers>
        <cacheDependency mode="InDatabase" checkExpriredInterval="200"/>
    </caching>


    slidingExpiration - The data will remain in the cache until two minutes passes without anything referencing it.
    Required. Time, in seconds, the page should be cached. Must be a positive integer.
    cacheDependency  - Establishes a dependency relationship between an item stored in an ASP.NET application's Cache object and a file, cache key, an array of either, or another CacheDependency object. The CacheDependency class monitors the dependency relationships so that when any of them changes, the cached item will be automatically removed.If you add an item to the cache that is dependent on another object, such as a file or array of files, the dependent item is automatically removed from the cache when the object changes.

    Caching is applied on a page level. In case you have project in Load Balanced Web Farm Environment you should set the mode to InDatabase. Thus, changes you make on one of the sites will be immediately reflected on the other sites.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Chris Dodge
    Chris Dodge avatar
    16 posts
    Registered:
    17 Dec 2009
    27 May 2010
    Link to this post
    Thanks for the help. I just wanted to confirm one of the settlings, you say to have:

    <cacheDependency mode="InDatabase" checkExpriredInterval="200" />

    But i noticed in another Forum post, the recommended value is:

    <cacheDependency mode="InDatabase" checkExpriredInterval="10" />

    Can you explain what "checkExpiredInterval" value means? Is this some polling mechanism where each server looks every N seconds to see if there's expired content.

    If this is true and the cache flushing occurs via a asynchronous timed polling architecture, will updates then take up to N seconds to be reflected on all servers?

    Thanks,

    Chris
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    27 May 2010
    Link to this post
    Hello Chris Dodge,

    checkExpriredInterval tells the servers to check if the cache is valid every N seconds. If a content item or a page has been edited the cache dependency for this item will be reset.

    Greetings,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Chris Dodge
    Chris Dodge avatar
    16 posts
    Registered:
    17 Dec 2009
    27 May 2010
    Link to this post
    Thanks for the quick response.

    If Sitefinity uses polling, can you give a good recommendation for what value in "checkExpiredInterval" which balances performance (not too many round trips to the DB) with edit responsiveness? I assume the value here is in Seconds, right?

    Also, is there a way programmatically via the Sitefinity object model to force flush caches? I'm thinking whether it might make sense to make a way for our editors to have a means to force flush the cache?

    Thanks again,

    Chris
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    27 May 2010
    Link to this post
    Hi Chris Dodge,

    checkExpriredInterval is in ms and its default value is 1000. You could use System.Web.HttpRuntime.UnloadAppDomain() which will clear the cache for the entire application. For instance create a button and call System.Web.HttpRuntime.UnloadAppDomain()

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
6 posts, 0 answered