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

Forums / Developing with Sitefinity / Preferred method for clearing page cache

Preferred method for clearing page cache

6 posts, 0 answered
  1. Kevin Lonigro
    Kevin Lonigro avatar
    7 posts
    Registered:
    28 Apr 2006
    02 Sep 2007
    Link to this post
    From code, what is the preferred Sitefinity method for clearing the page cache in order to reflect current pages on a cached page?

    I have tried Page.CmsPage.CmsProvider.ClearPageCache() which did not work as expected.
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    03 Sep 2007
    Link to this post
    Hi Kevin,
    You can try using the Clear() method that is a member of IPageCacheManager interface. It clears the cache information. For example:

    pagesCache.Clear();

    pagesCache is a variable of type IPageCacheManager.
    Hope this helps.

    Sincerely yours,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Kevin Lonigro
    Kevin Lonigro avatar
    7 posts
    Registered:
    28 Apr 2006
    03 Sep 2007
    Link to this post
    In researching which classes implement IPageCacheManager, I found Telerik.Cms.MemoryPageCacheManager and Telerik.Cms.DatabasePageCacheManager.  I instantiated new objects as I did not find any helper objects on CmsPage then executed the Clear method with no success. The cached pages were still reflecting cached information.

    My situation involves dynamically rewriting a menu name from "Sign-In" to "Sign-Out" depending on user login status.

    On non-cached pages, the rewritten menu names appear as expected when a user signs out but on a cached page the "Sign-Out" remains although it should read "Sign-In".  I observed this behavior both before and after using the cache clear methods noted above.

    I did observe that when a page like a blog is selected it does refresh or clear the cache and the "Sign-Out" on the cached page would correctly reflect the updated "Sign-In" menu name.  How does activating a blog correctly clear the cache?

    Any suggestions?

  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    04 Sep 2007
    Link to this post
    Hi Kevin,

    Try to call UrlHelper.OutputCache.Clear() in your implementation. This should help you.

    As for the DatabasePageCacheManager: you need it only if the cache persistence mode is InDatabase.Its Clear() method just deletes the data in sf_PagesOutputCache table.

    Hope this is helpful.

    Sincerely yours,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Kevin Lonigro
    Kevin Lonigro avatar
    7 posts
    Registered:
    28 Apr 2006
    05 Sep 2007
    Link to this post

    Thanks for the suggestion, Telerik.Cms.Web.UrlHelper.OutputCache.Clear() worked as expected in refreshing the menu links for a cached page.
    The UrlHelper class has a number of useful properties and methods. 

    FYI - As I was looking at the different members, I noticed a misspelling on the following: Telerik.Cms.Web.UrlHelper.GetRequsetedPaht, I assume it should read "Path".  Is this something that I should report with a bug or suggestion ticket or is the forum avenue fine?

    Thanks again for the cache clear advice.

  6. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    05 Sep 2007
    Link to this post
    Hello Kevin,

    You are right that there was a misspelling in SP2 for the GetRequsetedPath method but this was noticed and it is already fixed.

    Sincerely yours,
    Pepi
    the Telerik team

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