0

In my 9.0.2 MVC site, I have a personalized rendering on a page that has personalization enabled.

Below is a contrived example of a set of rules that should always result in the rendering being hidden.

Personalization rules

In plain English:

  1. If the condition is true, hide.
  2. If the condition is false, hide.

To drive the point home, I know for a fact that my custom condition always returns false:

public class SomeCondition<T> : TrueCondition<T> where T : RuleContext
{
  protected override bool Execute(T ruleContext)
  {
    return false;
  }
}

While this is a contrived example, the rendering should always be hidden in this scenario.

Replicating the Issue

The page where this rendering can be viewed requires authentication. When I log in via private browser tab while debugging, I can 100% confirm that my custom condition is evaluated, and that it always evaluates to false, which is what I am expecting. The component is hidden correctly.

However, if I recycle the app pool and reload the page, the rendering becomes visible and I can see that the breakpoint for my custom condition is never hit. It is as if personalization has been skipped entirely. I can also see this happening on other renderings.

Temporary "Fixes"

Method 1 If I clear the cache via /sitecore/admin/cache.aspx and refresh the page, the personalization starts working again, my custom rule gets evaluated, and the rendering is hidden.

If I smart publish any item, personalization starts working again, even if the item I publish was skipped.

Method 2

The problem seems to disappear entirely when I disable xDB but leave Tracking enabled:

<setting name="Xdb.Enabled" set:value="false" />
<setting name="Xdb.Tracking.Enabled" set:value="true" />

The Question

At its core, the rendering appears to be getting cached in a state by which personalization rules have not yet been applied.

What could cause this? Why does this issue only happen when xDB is enabled?

Analysis & Attempted Fixes

  • I don't see any obvious custom caching that could cause this problem.
  • We do have a custom overridden Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer (which I can see as part of the call stack when the custom condition is evaluated), but I don't see anything related to caching. It just calls base.Process(args); and does some extra processing around error logging.
  • Rendering caching is disabled on both the rendering in question and its parent renderings.
  • The cacheHtml setting is disabled on the site.
  • Removing the custom condition entirely and leaving only the default personalization of always hiding the rendering.
  • Recycling the app pool a second time does not resolve the issue.
  • Subsequent page refreshes does not resolve the issue.
  • Browser cache is disabled.
  • Session state is specified as follows in my web.config: <sessionState mode="InProc" cookieless="false" timeout="20"/>
  • There is also this in my web config:
<configuration>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
            <add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition=""/>
        </modules>
    </system.webServer>
</configuration>
5
  • Is your screenshot correct? It shows that both default and personalised variants are set to hide the component. I can think of two potential reasons for this behaviour: Sitecore HTML cache and a custom processor that turns off analytics/personalisation. Do you have any processor for cookie consent management that stops tracking, for example in the startAnalytics pipeline? Also, what are the cache settings on your rendering and wrapper renderings around it?
    – Anna Gevel
    Commented Jul 1, 2023 at 16:19
  • A personalisation rule that always returns false, will never have any effect on your rendering. Sitecore evaluates the rules from top to bottom and applies the first one that evaluates to true. If none are true then it will apply the default, which in this case is to hide. Try changing your condition to always return true and rerun tests. Commented Jul 2, 2023 at 9:18
  • Thanks @AnnaGevel & @Dean. I updated the question for greater clarity. Sitecore HTML cache is disabled. No cookie management. We do have a custom processor for startAnalytics, but I see no issues when tracing through it in terms of tracking requests. Wrapper renderings have cache disabled. It looks like this issue only happens when I have xDB enabled. Commented Jul 4, 2023 at 17:58
  • That's interesting, I assume you don't see any errors in Sitecore log? Is SC_ANALYTICS_GLOBAL_COOKIE in place for all requests? Another thing you can try is disabling robot detection to see if it recognises users as bots by mistake doc.sitecore.com/xp/en/developers/90/…
    – Anna Gevel
    Commented Jul 4, 2023 at 18:41
  • No errors. Disabling robot detection does not help. The SC_ANALYTICS_GLOBAL_COOKIE is in place: Domain: null Expires: {1/1/0001 12:00:00 AM} HasKeys: false HttpOnly: false Name: "SC_ANALYTICS_GLOBAL_COOKIE" Path: "/" SameSite: -1 Secure: false Shareable: false Value: "07797c675b34443387e1955fbfa9872b|False" Values: {07797c675b34443387e1955fbfa9872b%7cFalse} Commented Jul 8, 2023 at 3:20

1 Answer 1

0

This issue only happens when xDB is enabled AND when xDB is inaccessible due to being shut down or if it is experiencing SSL/TLS issues (expired certs, incorrect thumbprints, missing cert permissions for app pools). This can cause unexpected behavior that can give the illusion that caching or session state is the issue, when in fact it is not.

As is usually the case, if something isn't working as expected, aim to fix any major Sitecore errors that appear in the logs as part of your troubleshooting.

Further reading:

Does xConnect/xDB need to be fully enabled and working for rendering personalization rules to work?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.