Copied to clipboard

Flag this post as spam?

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


  • Jeff Lewis 14 posts 84 karma points
    Mar 07, 2020 @ 17:55
    Jeff Lewis
    0

    Dynamic Navigation - Member Has Access

    Hello,

    I have an issue where my dynamic navigation view is causing very slow page load times because it has to check whether a member has access for every visible piece of navigation content via code similar to this:

    IEnumerable<IPublishedContent> navigationPages = homePage.Children(x => x.IsVisible());
    
    @foreach (var item in navigationPages)
          { var access = Umbraco.MemberHasAccess(item.Path); }
    

    I have Public Access set up for all of my member-area content by using the member groups, which I believe is correct, but I wonder if there's a better way of doing this than using @Umbraco.MemberHasAccess(item.Path);?

    I see a lot of SQL queries in the profiler in Visual Studio for every page request, which are significantly reduced along with page load times if I comment out the line checking Umbraco.MemberHasAccess(item.Path);.

    Are there any alternatives to this? Am I doing this correctly?

    Thanks

    -jeff

  • Shaishav Karnani from digitallymedia.com 354 posts 1638 karma points
    Mar 09, 2020 @ 08:33
    Shaishav Karnani from digitallymedia.com
    0

    Hi Jeff,

    You need to apply caching of data to ensure Navigation is cached per user. Therefore, you will start reducing queries quite a lot rather than calling for each page.

    1) HttpContext.Current.Cache - For data cache 2) or use MemoryCache.Default

    Hope that helps to solve your issue.

    Cheers,

    Shaishav

Please Sign in or register to post replies

Write your reply to:

Draft