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

Forums / Developing with Sitefinity / What does cacheDependency do ?

What does cacheDependency do ?

8 posts, 0 answered
  1. hibri
    hibri avatar
    12 posts
    Registered:
    06 Dec 2006
    27 Jun 2007
    Link to this post
     In the Sitefinity web.config, inthe telerik dataAccess section there is a cacheDepency entry. What does this do, and how does this affect the cms engine.
    I haven't seen any documentation for this yet. It is set to "InMemory" in the default install. Is there a database cache dependency that will work with SQL server 2000 databases ?
    I'm interested in how this will help me in load balanced environments

  2. Vassil Daskalov
    Vassil Daskalov avatar
    261 posts
    Registered:
    18 May 2013
    28 Jun 2007
    Link to this post
    Hi hibri,

    The cacheDependancy attribute inside dataAccess is used to specify whether you want to cache your pages. So when there is no new change from the last load of the page, it does not recreate the page once again but rather gets already built copy. This is very useful as it lowers the page loading significantly and even if somebody loads a page for the first time creating a cached version, anybody else who gets to the page will use the cached version.

    The cacheDependancy takes three values: None, InMemory and InDatabase. With None you turn the feature off, with InMemory the cache is preserved in the memory so when the application is restarted the cache gets lost. With InDatabase all the information goes to the database. So I think this property should do your job. In load balanced environment you should use the InDatabase option.

    All the best,
    Vassil Daskalov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. hibri
    hibri avatar
    12 posts
    Registered:
    06 Dec 2006
    28 Jun 2007
    Link to this post
    Thanks Vassil,

    When using the InDatabase option, how is the cache notified when pages are changed ?
    How often does sitefinity refresh content when using the database option ?
  4. Vassil Daskalov
    Vassil Daskalov avatar
    261 posts
    Registered:
    18 May 2013
    28 Jun 2007
    Link to this post
    Hi hibri,

    There is a DatabaseCacheDependencyHandler which is responsible for the notification. Its use is integrated inside the system and is notified on every page save or publish. In case you are building your own control or module, you can subscribe to the handler as well.

    Otherwise changes are being checked every second. This is by default you could specify another value (in milliseconds) from the checkExpriredInterval attribute of the dataAccess element. The content is refreshed on change.

    Please, let us know if we could help you further.

    Best wishes,
    Vassil Daskalov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. hibri
    hibri avatar
    12 posts
    Registered:
    06 Dec 2006
    28 Jun 2007
    Link to this post
    Thanks Vassil,
    That explains a lot. I just couldn't find any explanation in the documentation. Thanks for clearing it up.
  6. Vassil Daskalov
    Vassil Daskalov avatar
    261 posts
    Registered:
    18 May 2013
    03 Jul 2007
    Link to this post
    Hello hibri,

    It seems that there was a misunderstanding on my side about the cache dependency for which I apologize. With the cacheDependency element of the dataAccess node you control the cache dependency behavior.

    Cache dependency is a technique used to track changes for objects subscribed to it. It is realized as a handler and any objects can subscribe to it. Any objects can also notify the cache dependency for changes and it would update its information (if it preserves it in a database) and on its turn would inform any or all of the subscribers about the change. The Mode attribute of the cacheDependency element:

    <dataAccess>
        <cacheDependency mode="InDatabase" />
    </
    dataAccess>
     
    is used to specify how this technique would be realized. It has the following values: InDatabase and InMemory. When InDatabase is selected, it stores dates in the database and checks against the current date for any changes. The InMemory mode uses notify functions called on every change. Therefore, when you are working in load balanced environment, you should use the InDatabase mode as there are more than one processes and they cannot notify each other.

    The caching attribute inside the telerik/cms element:

    <
    cms caching="InMemory">
     
    is used to specify whether the page caching would be switched off or where the page rendered output would be saved. It takes the values None, InMemory and InDatabase. When None is selected, it turns the cache off no matter if you specify some page to be cached from the user interface. If the InMemory mode is set, the output is preserved in the memory. If the InDatabase is chosen, the page output goes to the database. The InMemory mode offers better performance but if you are limited from memory, it would be better to switch to database mode.

    Hope this gives you a better glance over the cache dependency and how it is realized in Sitefinity. Once again I am sorry for misleading you earlier. Hope it did not cause you any trouble.

    Greetings,

    Vassil Daskalov
    the Telerik team


    Instantly find answers to your questions at the new Telerik Support Center
  7. hibri
    hibri avatar
    12 posts
    Registered:
    06 Dec 2006
    03 Jul 2007
    Link to this post
    Hi Vassil,
    I'm still testing this scenario, no problems yet :)

    In my load balanced environment if i have
    <cacheDependency mode="InDatabase" /> and
    <cms caching="InMemory">

    Am I right in thinking that the rendered page output is stored on each webserver's memory will be refreshed or expired when the content is modified in the database ? or do i control the expiration using ?

    <cms caching="InMemory" checkExpiredInterval="3000">




  8. Vassil Daskalov
    Vassil Daskalov avatar
    261 posts
    Registered:
    18 May 2013
    03 Jul 2007
    Link to this post
    Hi hibri,

    If you change the database content through the Sitefinity API, you can be sure that the cache will be refreshed. In case you want to set some expiration interval for which the page cache will be deleted, you could set it through the cacheDuration attribute of the cms element. By default it is set to 1200 seconds(20 min). If you want to stop, it you could set it to 0.

    Also, the checkExpiredInterval is an attribute of the cacheDependency element, not the cms, and specifies the interval for which the cache dependency would check for changes in the database. It is not used when the cache dependency attribute is set to InMemory mode.

    All the best,
    Vassil Daskalov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
8 posts, 0 answered