Copied to clipboard

Flag this post as spam?

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


  • Simon Dingley 1470 posts 3427 karma points c-trib
    Oct 23, 2018 @ 16:25
    Simon Dingley
    0

    Load Balanced Site - PageCacheRefresher.CacheUpdated Does Not Seem to Fire on Slave Server

    I have a large multi-site install load balanced using a Flexible Load Balancing setup.

    I am subscribing to the PageCacheRefresher.CacheUpdated event in the ApplicationStarted event of my ApplicationEventHandler as follows:

    protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
    {
        PageCacheRefresher.CacheUpdated += PageCacheRefresher_CacheUpdated;
    }
    
    private static void PageCacheRefresher_CacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs e)
    {
        if (UmbracoContext.Current == null) return;
    
        LogHelper.Info<EventHandlers>("Page cache refreshed.");
    }
    

    Both servers are registered in the umbracoServer table server correctly and the umbracoApplicationUrl is set to the primary domain for the site in the umbracoSettings.config file.

    Changes are published on Server 1 fine and the PageCacheRefresher.CacheUpdated event is fired on the master. The cache instructions in the database are processed by the slave server but the PageCacheRefresher.CacheUpdated event does not appear to fire on the slave server yet the lastsync value is updated and so is the umbraco.config cache file.

    Any ideas what might cause that to happen?

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Oct 24, 2018 @ 06:45
    Dave Woestenborghs
    100

    Hi Simon,

    What version are you running ? We noticed that in one of the latest versions UmbracoContext.Current is always null in the cache updated event.

    Could you remove that line to check this and see if something is written to the log ?

    Dave

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Oct 24, 2018 @ 06:54
    Simon Dingley
    0

    Hi Dave

    This site is running 7.10.4. I will see about removing that line this morning in the next deployment and let you know.

    Thanks, Simon

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Oct 24, 2018 @ 08:39
    Simon Dingley
    0

    You are indeed correct Dave - UmbracoContext.Current == null now on the slave server when the event is triggered so thanks for pointing that out.

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Oct 24, 2018 @ 08:49
    Dave Woestenborghs
    1

    Hi Simon,

    I noticed this as well. In earlier versions this was set.

    This was a breaking change in 7.8.0 I know found out : https://issues.umbraco.org/issue/U4-10150

    Maybe you can create a fake umbraco context if you need it.

    Don't know if this gist is still working : https://gist.github.com/sniffdk/7600822

    Make sure to read all the comments

    Dave

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Oct 24, 2018 @ 08:57
    Simon Dingley
    0

    Thanks Dave, that's really useful to have some context relating to the change in behaviour and it turns out it addresses another unresolved issue I kept seeing in regards to "DISTRIBUTED CACHE NOT UPDATED" errors in the logs in previous versions.

    Maybe you can create a fake umbraco context if you need it.

    I think in actual fact I can remove the check now as it is already redundant based on the issue you have referenced.

    Thanks for your help Dave, much appreciated.

Please Sign in or register to post replies

Write your reply to:

Draft