Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ivan 165 posts 543 karma points
    Mar 07, 2017 @ 14:46
    Ivan
    0

    Disable caching in umbracoHelper.TypedContent

    Hi guys!

    Simple line of code that returns IPublishedContent:

    var cachedNode = umbracoHelper.TypedContent(1234);
    

    My issues is that the code above returns cashed contend whereas there're cases where I would rather want NOT cashed content to be returned. For example, in integration tests I need to perform testing against NOT cached data only.

    One of my ideas was: umbracoContext.InPreviewMode = true, but that didn't work.

    Any help on the subject?

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Mar 09, 2017 @ 17:07
    Alex Skrypnyk
    100

    Hi Ivan

    Try to disable xml cache in /config/umbracoSettings.config:

       <!-- Enable / disable XML content cache -->
       <XmlCacheEnabled>False</XmlCacheEnabled>
    

    Another way is to use Content service to work with data from database directly, like this:

        ApplicationContext.Current.Services.ContentService.GetById(1234)
    

    Thanks,

    Alex

  • Ivan 165 posts 543 karma points
    Mar 09, 2017 @ 17:28
    Ivan
    1

    Thanks, Alex! I think it should work with ContentService.

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Mar 09, 2017 @ 17:29
    Alex Skrypnyk
    0

    You are welcome, glad to help!!!

    /Alex

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies