Copied to clipboard

Flag this post as spam?

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


  • Беззубов Владислав 3 posts 71 karma points
    Dec 16, 2019 @ 11:24
    Беззубов Владислав
    0

    [v8] Bug. A page with a single field starts to work slower when the site is enlarged

    Hello

    EN: A page with a single field starts to work slower when the site is enlarged

    RU: Страница с одним полем начинает работать медленнее при увеличении сайта

    Examples (Umbraco 8.2.2 + SQL Server 2019):

    1. The site contains 10 pages (10-50 ms) enter image description here
    2. The site contains 50-100 pages (150-250 ms) enter image description here
    3. The site contains 500-1000 pages (350-700 ms)
    4. etc.

    EN: The site is very fast at first, but slows down with the growth of pages. (he functionality of the page does not change, but slows down over time)

    RU: Сайт сначала очень быстрый, но замедляется с ростом страниц. (Функционал страницы не меняется, но со временем замедляется)

    https://github.com/umbraco/Umbraco-CMS/issues/7329

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Dec 16, 2019 @ 12:50
    Alex Skrypnyk
    0

    Hi Vlad

    Can you, please, share the source code of the page? Maybe something can be fixed in code.

    Thanks,

    Alex

  • Беззубов Владислав 3 posts 71 karma points
    Dec 16, 2019 @ 13:18
    Беззубов Владислав
    1

    Contacts:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        // Контакты
        Layout = "_master.cshtml";
    }
    
    @section Head {
        @{ Html.RenderPartial("_Head"); }
    }
    
    @* Хлебные крошки *@
    @{ Html.RenderPartial("_Breadcrumb"); }
    
    @* Заголовок *@
    @{ Html.RenderPartial("_Main_Title"); }
    
    <div class="wis-common-global">
        <div class="wis-manufacturing wis-manufacturing__contacts">
            <div class="wis-universal_page_2">
                @* Текст *@
                @{ Html.RenderPartial("_Main_Text"); }
            </div>
        </div>
    </div>
    
    @* Яндекс карта + Обратная связь *@
    <div class="wis-production">
        <div class="wis-common-global">
            @* Обертка *@
            <div class="wis-production-wrapper">
                @* Яндекс карта *@
                <div class="wis-production-advantages">
                    <div class="wis-map-block" id="wis-map"></div>
                </div>
    
                @* Обратная связь *@
                @{ Html.RenderPartial("_Feedback"); }
            </div>
        </div>
    </div>
    

    _Breadcrumb:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        // Хлебные крошки
        Layout = null;
    
        IEnumerable<IPublishedContent> selection = Model.Ancestors();
    }
    
    @if (selection.Any())
    {
        <div class="wis-common-global">
            <div class="wis-common-example">
                <div class="wis-breadcrumb">
                    <ul>
                        @* For each page in the ancestors collection which have been ordered by Level (so we start with the highest top node first) *@
                        @foreach (IPublishedContent item in selection.OrderBy(p => p.Level))
                        {
                            <li class="wis-breadcrumb-elem">
                                <a href="@item.Url">
                                    @item.Name
                                </a>
                            </li>
                        }
                        <li class="wis-breadcrumb-elem">
                            @Model.Name
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    }
    

    Main_Title:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        // Контент (Заголовок)
        Layout = null;
    
        //Заголовок
        string el_Main_Title = Model.Value<string>("Main_Title");
    }
    
    @* Контент (Заголовок) *@
    <div class="wis-common-global">
        <div class="wis-catalog-title-wrapper">
            <div class="wis-catalog-title wis-catalog-title__center">
                @if (!string.IsNullOrWhiteSpace(el_Main_Title))
                {
                    <h1>@el_Main_Title</h1>
                }
            </div>
        </div>
    </div>
    

    RU: Если что-то еще требуется, напишите, пожалуйста.

    EN: Is there anything else you need to clarify?

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Dec 17, 2019 @ 20:20
    Alex Skrypnyk
    0

    Hi Vlad

    Thanks, the code looks good, shouldn't be a problem. Try to use MiniProfiler to identify what is taking the time, MiniProfiler documentation is here - https://our.umbraco.com/documentation/getting-started/Code/Debugging/

    I will ask friends what it can be in Umbraco version 8.2.

    Thanks, Alex

  • Thomas Rydeen Skyldahl 44 posts 222 karma points
    Dec 17, 2019 @ 23:07
    Thomas Rydeen Skyldahl
    0

    A good practice is to execute IEnumerables up front.

    In this case you have the following IEnumerables

    1. IEnumerable<IPublishedContent> selection = Model.Ancestors();
    2. selection.Any()
    3. selection.OrderBy(p => p.Level)

    This can be written as

    IPublishedContent[] selection =  Model.Ancestors().OrderBy(p => p.Level).ToArray();
    

    then the collection build upfront.

    Then the selection.Any() can use the selection.Length internally, and the ordering is already performed the first time around, as I remember it the Model.Ancestors also returns in an ordered list by level, to if you need to reverse the order, you could also just perform an .Reverse() if you want the breadcrumb to be reversed.

    The above are small things but they might help.

    Do you have any menu generation running in the master.cshtml or head.cshtml, that isn't included in the above examples, as menu generation is usually the problem in sites with a larger amount of nodes.

    They might benefit from the same optimization as described above, or look into output caching for the generated menues.

  • Беззубов Владислав 3 posts 71 karma points
    Dec 18, 2019 @ 06:05
    Беззубов Владислав
    0

    Hi Alex

    Thanks

    --

    Hi Thomas

    Thanks

    --

    MainText.cshtml:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        // Текст (Контент)
        Layout = null;
    
        // Текст
        string el_Main_Text = Model.Value<string>("Main_Text");
    }
    
    @Html.Raw(el_Main_Text)
    

    _master.cshtml:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        Layout = null;
    
        string Guid_Salt = "20191217_1400";
    
        #region Мета-теги
    
        // Мета тег - NoIndex (запрет индексации текста на странице)
        bool meta_NoIndex = false;
        if (Model.HasValue("Meta_NoIndex"))
        {
            meta_NoIndex = Model.Value<bool>("Meta_NoIndex");
        }
    
        // Мета тег - NoFollow (запрет индексации ссылок на странице.)
        bool meta_NoFollow = false;
        if (Model.HasValue("Meta_NoFollow"))
        {
            meta_NoFollow = Model.Value<bool>("Meta_NoFollow");
        }
    
        // Мета тег - robots
        string meta_Robots = "";
        if (meta_NoIndex && meta_NoFollow)
        {
            meta_Robots += "noindex, follow";
        }
        else
        {
            if (meta_NoIndex)
            {
                meta_Robots = "noindex";
            }
            else
            {
                meta_Robots = "follow";
            }
        }
    
        // Мета тег - description
        string meta_Description = "";
        if (Model.HasValue("Meta_Description"))
        {
            meta_Description = Model.Value<string>("Meta_Description");
        }
    
        // Мета тег - keywords
        string meta_Keywords = "";
        if (Model.HasValue("Meta_Keywords"))
        {
            meta_Keywords = Model.Value<string>("Meta_Keywords");
        }
        #endregion
    }
    <!DOCTYPE html>
    <html lang="ru">
    <head>
        @* Настройки *@
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="msapplication-tap-highlight" content="no" />
        <meta charset="utf-8" />
        <meta content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.1,user-scalable=yes" name="viewport" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="format-detection" content="address=no" />
    
        @* Мета-теги *@
        @if (meta_NoIndex || meta_NoFollow)
        {
            <meta name="robots" content="@meta_Robots" />
        }
        @if (!string.IsNullOrWhiteSpace(meta_Description))
        {
            <meta name="description" content="@meta_Description" />
        }
        @if (!string.IsNullOrWhiteSpace(meta_Keywords))
        {
            <meta name="keywords" content="@meta_Keywords" />
        }
    
        @* Favicon *@
    
        @* CSS *@
        @RenderSection("head_top", required: false)
        <link href="/_c/base.min.css?@Guid_Salt" rel="stylesheet" />
        @RenderSection("head", required: false)
    </head>
    <body>
        @* Шапка *@
        @Html.Partial(partialViewName: "_Header", model: Model)
    
        @* Контент *@
        @RenderBody()
    
        @* Подвал *@
        @Html.Partial(partialViewName: "_Footer", model: Model)
    
        @* Модальное окно - Оставить заявку *@
        @Html.Partial(partialViewName: "_Feedback_Modal", model: Model)
    
        @* Скрипты *@
        @RenderSection("scripts_top", required: false)
        <script src="/scripts/bundle.min.js?@Guid_Salt"></script>
        @RenderSection("scripts", required: false)
    </body>
    </html>
    

    _Header.cshtml:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        // Шапка
        Layout = null;
    
        // Главная страница
        IPublishedContent selection_Home = HtmlHelpers.Get_Page(CurrentPage: Model, ContentTypeAlias: "Doc_Home");
    
        // Поля шапки
    
        // Шапка > Лого > Изображение
        IPublishedContent el_Header_Logo_Image = selection_Home.Value<IPublishedContent>("Header_Logo_Image");
    
        // Шапка > Лого > Текст
        string el_Header_Logo_Text = selection_Home.Value<string>("Header_Logo_Text");
    
        // Шапка > Телефон
        Link el_Header_Phone = selection_Home.Value<Link>("Header_Phone");
    
        // Шапка > Эл. почта
        Link el_Header_Email = selection_Home.Value<Link>("Header_Email");
    
        // Шапка > Меню
        IEnumerable<Link> el_Header_Nav = selection_Home.Value<IEnumerable<Link>>("Header_Nav");
    
        // Шапка > Текст кнопки "оставить заявку"
        string el_Header_Order_Text = selection_Home.Value<string>("Header_Order_Text");
    
    }
    
    @* Шапка *@
    <header>
        <div class="wis-header">
            <div class="wis-common-global">
                <div class="wis-header-wrapper">
                    @* Логотип *@
                    <div class="wis-header-logo">
                        <a href="/" class="wis-header-logo-img">
                            @if (el_Header_Logo_Image != null)
                            {
                                <img src="@el_Header_Logo_Image.Url" alt="" />
                            }
                            <span>@el_Header_Logo_Text</span>
                        </a>
                    </div>
                    @* Поиск *@
                    <div class="wis-header-search-wrapper">
                        <div class="wis-header-search">
                        </div>
                    </div>
                    @* Контакты *@
                    <div class="wis-header-contacts">
                        @if (el_Header_Phone != null)
                        {
                            <div class="wis-header-contacts-phone">
                                @Html.WIS_Link(Link: el_Header_Phone)
                            </div>
                        }
                        @if (el_Header_Email != null)
                        {
                            <div class="wis-header-contacts-mail">
                                @Html.WIS_Link(Link: el_Header_Email)
                            </div>
                        }
                    </div>
                </div>
            </div>
        </div>
    
        @* Меню *@
        <div class="wis-menu">
            <div class="wis-common-global">
                <div class="wis-menu-wrapper">
                    <div class="wis-menu-list">
                        @if (el_Header_Nav != null && el_Header_Nav.Any())
                        {
                            <ul>
                                @foreach (var elem in el_Header_Nav)
                                {
                                    IPublishedContent page = Umbraco.Content(elem.Udi);
                                    string elem_Class = "";
                                    List<IPublishedContent> page_Children = null;
                                    if (page != null && page.ContentType.Alias == "Doc_Catalog")
                                    {
                                        page_Children = page.Children().Where(p => p.ContentType.Alias == "Doc_Category").ToList();
                                        if (page_Children != null && page_Children.Any())
                                        {
                                            elem_Class = "class=\"wis-menu-list-drop\"";
                                        }
                                    }
                                    <li @Html.Raw(elem_Class)>
                                        @Html.WIS_Link(Link: elem)
                                        @if (page_Children != null && page_Children.Any())
                                        {
                                            <ul>
                                                @foreach (var item in page_Children)
                                                {
                                                    <li><a href="@item.Url">@item.Name</a></li>
                                                }
                                            </ul>
                                        }
                                    </li>
                                }
                            </ul>
                        }
                    </div>
                    @* Обратный звонок *@
                    @if (!string.IsNullOrWhiteSpace(el_Header_Order_Text))
                    {
                        <div class="wis-menu-feedback ">
                            <button type="button" data-toggle="modal" data-target="#wis-modal-guid-1">
                                <span class="wis-menu-feedback-text">@el_Header_Order_Text</span>
                            </button>
                        </div>
                    }
                </div>
            </div>
            @if (Model.ContentType.Alias != "Doc_Home")
            {
                <div class="wis-menu-line"></div>
            }
        </div>
    </header>
    

    HtmlHelpers.GetPage(CurrentPage: Model, ContentTypeAlias: "DocHome") (it is used not only to get the main page, but also to get the category page from any level of the subcategory):

            /// <summary>
            /// Получение страницы в зависимости от дочерней страницы
            /// </summary>
            /// <param name="CurrentPage">Текущая страница</param>
            /// <param name="ContentTypeAlias">Псевдоним типа контента страницы</param>
            /// <returns></returns>
            public static IPublishedContent Get_Page(IPublishedContent CurrentPage, string ContentTypeAlias)
            {
                IPublishedContent Get(IPublishedContent item)
                {
                    if (item == null)
                    {
                        return null;
                    }
    
                    if (item.ContentType.Alias == ContentTypeAlias)
                    {
                        return item;
                    }
                    return Get(item.Parent);
                }
    
                return Get(CurrentPage);
            }
    
  • 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