Copied to clipboard

Flag this post as spam?

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


  • Enny 12 posts 63 karma points
    Apr 10, 2019 @ 07:52
    Enny
    0

    Macro Parial View always cached (even if caching disabled)

    I've got a contact form as Partial View Marcro. The Macro is always cached, even if i set "Cache by page" to off, "Cache period" to 0 and "Cache personalized" to off.

    Sample cshtml:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @DateTime.Now.Ticks
    

    Result: Same Number, when accessing the page.

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Apr 10, 2019 @ 10:50
    Alex Skrypnyk
    0

    Hi Enny

    Can you show the master page view? Maybe caching is on the page level?

    Alex

  • Enny 12 posts 63 karma points
    Apr 11, 2019 @ 06:17
    Enny
    0

    Thank you! Here is the master:

        @inherits Umbraco.Web.Mvc.UmbracoViewPage
        @using Umbraco.Web;
        @{
            Layout = null;
            string companyName = "Test";
        }
        <!DOCTYPE html>
        <html>
        <head>
            <meta http-equiv="content-type" content="text/html; charset=utf-8">
            <meta charset="utf-8">
            <meta lang="de-ch">
            <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
            <title>@(string.IsNullOrEmpty(Model.Value<string>("title"))?Model.Name:Model.Value<string>("title")) - @companyName</title>
            <meta name="author" content="@companyName">
            <link rel="stylesheet" type="text/css" href="/css/bootstrap-reboot.min.css" />
            <link rel="stylesheet" type="text/css" href="/css/site.css?1" />
            <link rel="stylesheet" type="text/css" href="/css/content.css" />
            @RenderSection("head", required: false)
      </head>
        <body>
            @RenderSection("bodyTop", required: false)
            <nav class="navbar">
                <div class="container-fluid nav-top-container">
                    <a href="~/" class="nav-top-logo"></a>
                        <ul class="nav-top">
                <li class="nav-item">
                    <a class="nav-link" href="~/">Start</a>
                </li>
    
        @{
            var tmenu = Umbraco.ContentAtRoot().First(x=>x.Name=="TopMenu")
            .Children("menuItem")
            .Where(x => x.IsVisible())
            .OrderBy(x => x.SortOrder);
            foreach(MenuItem i in tmenu){
                string href = "";
                if(string.IsNullOrEmpty(@i.ExternalUrl)){
                    if(i.Content!=null) {
                     href = (i.Content as ChildPage).Url;
                    } else {
                        href = "/";
                    }
                } else {
                    href = i.ExternalUrl;
                }
                <li class="nav-item">
                    <a class="nav-link" href="@href">@i.Name</a>
                    <div class="nav-item-hint">
                    @i.MenuText
                    </div>
                </li>
            }
        }
                        </ul>
                </div>
            </nav>
            <div class="container-fluid body-content">
                @RenderBody()        
            </div>
                <footer class="container-fluid">
                    <div class="row">
        @{
            for(var m = 1;m <= 3;m++){
                <div class="col-sm-4">
                <ul class="nav-bottom">
                @{
                    var bmenu = Umbraco.ContentAtRoot().First(x=>x.Name==$"BottomMenu{m}")
                    .Children("menuItem")
                    .Where(x => x.IsVisible())
                    .OrderBy(x => x.SortOrder);
                    foreach(MenuItem i in bmenu){                
                        string href = "";
                        if(string.IsNullOrEmpty(@i.ExternalUrl)){
                            if(i.Content!=null) {
                                href = (i.Content as ChildPage).Url;
                            } else {
                                href = "/";
                            }
                        } else {
                            href = i.ExternalUrl;
                        }
                        <li class="nav-item">
                            <a  class="nav-link" href="@href"><span class="">@i.Name</span><small>@i.MenuText</small></a>
                        </li>
                    }
                }
                </ul>
                </div>    
            }
        }
                    </div>
                    <p class="text-center small mt-5">
                        &copy; @DateTime.Now.Year - @companyName<br />
                    </p>            
                </footer>
        </body>
        </html>
    
  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Apr 11, 2019 @ 06:25
    Dave Woestenborghs
    0

    Hi Enny,

    I see you are using a Macro Partial view. And it seems that you set the caching correctly.

    However I don't see how you are rendering it. Are you rendering it self some where in the view. Or does the editor place it in a rich text field or in a grid component.

    Maybe publishing the page that shows the macro will solve your problem.

    Dave

  • Enny 12 posts 63 karma points
    Apr 11, 2019 @ 06:35
    Enny
    0

    It's rendered via @Model.Value("bodyText") in a child view. The Macro is inserted in an RichText via Editor... Publishing the containing page, invalidates the Cache only one time. Same Code worked under UMB7.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Apr 11, 2019 @ 07:40
    Dave Woestenborghs
    0

    Hi Enny,

    If it reproducable it's best to create a issue at : https://github.com/umbraco/Umbraco-CMS/issues

    Please describe the steps on how to reproduce. Include as much information as possible.

    Dave

  • Enny 12 posts 63 karma points
    Apr 12, 2019 @ 07:54
    Enny
    0

    Thank you Dave and Alex!

  • Marko Milošević 2 posts 72 karma points
    Jul 16, 2019 @ 12:55
    Marko Milošević
    0

    Hello all,

    I have a similar issue but didn't find any open or closed issue on https://github.com/umbraco/Umbraco-CMS/issues

    For me the problem is with reading cookies from macro. I delete or add cookies through javascript and when going to cart page I am using the macro to list all added items from cookie. If I recycle app pool everything works as expected, but if then I delete one item the cookie changes, but the cart page doesn't read the cookie again on refresh.

    This post was the most similar issue as mine. I don't know if I didn't search the issues page enough but didn't find that is it resolved or closed.

    If someone has a link to issue I would be very thankful, if not that's also good cause I will open the issue then :)

Please Sign in or register to post replies

Write your reply to:

Draft