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?
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
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:
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
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
is working on a reply...