Sitecore Cache Issue

2019-09-08 04:41发布

I set "cacheHtml=true" in web.config file and set sublayout's (ascx file) cache setting. Whenever I reflash the page, I can see the increasing "From Cache" count in admin page. However, the sublayout(.ascx) doesn't get all its template field values on the page.

Suppose that there is CSS class name, like "nav-list", in its template field and HTML result should look like this.

<div class="nav-list">
something
</div>

But, if I check "cacheable", it shows like this. Otherwise, it shows correct style.

<div class=" ">
something
</div>


I checked:

Checked - Cacheable
Checked - Vary by Data
Checked - Vary by Parameters
Checked - Vary by Query String

What is the issue?

=================== Update ====================

This is the result when I DIDN'T check "Cacheable". (Correct Layout)

<div id="cloud-header">
    <div class="navtacular-cover"></div>
    <nav class="navtacular navtacular-theme-simple navtacular-variant-dark container block-center">
        <h1 class="navtacular-label">
            <i class="icon-reorder"></i>
        </h1>
        <ul class="navtacular-list">
            <li id="" class="navtacular-item">
            <li id="" class="navtacular-item">
            <li id="" class="navtacular-item">
            <li id="" class="navtacular-item">
            <li id="" class="navtacular-item">
        </ul>
    </nav>

This is the result when I DID check "Cacheable". All class values which are from datasource are empty.

<div id="cloud-header">
    <nav class="">
        <h1 class="">
            <i class=""></i>
        </h1>
        <ul class="">
            <li id="" class="navtacular-item">
            <li id="" class="navtacular-item">
            <li id="" class="navtacular-item">
            <li id="" class="navtacular-item">
            <li id="" class="navtacular-item">
        </ul>
    </nav>

This is the code for all class names which show empty.

<asp:View ID="viewNormalMode" runat="server">
    <nav class='<% Response.Write(myDataSourceItem.Fields["Nav Bar Class"]); %>'>
        <h1 class='<% Response.Write(myDataSourceItem.Fields["Label h1 Class"]); %>'>
            <i class='<% Response.Write(myDataSourceItem.Fields["Label i Class"]); %>'></i>
            <% Response.Write(myDataSourceItem.Fields["Nav Bar Label"]); %></h1>
        <ul class='<% Response.Write(myDataSourceItem.Fields["ul Class"]); %>'>
            <asp:Literal ID="linkObjects" runat="server"></asp:Literal>
        </ul>
    </nav>
</asp:View>

The class name is from another item which has different template fields, called NavBarLinkItem. In the NavBarLinkItem templates, there are fields (url, li Class, a Class, li Id, etc...).

Again, the original nav sublayout uses datasource to get those values.

0条回答
登录 后发表回答