Copied to clipboard

Flag this post as spam?

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


  • Jesse Andrews 191 posts 716 karma points c-trib
    Apr 27, 2022 @ 22:32
    Jesse Andrews
    0

    SEOChecker.config is not updated on all servers when editing it via the umbraco backoffice

    SEOChecker Version: 2.11.2

    I ran into this issue in a load balanced site. Editing the content in umbraco only updated SEOChecker.config on the cms server and didn't apply the change to the front end servers. Should be fixable, but requires some tinkering with SEOChecker's innards. A cache refresher needs to be added to inform the other servers about the change so that they make the needed updates on there side.

    Below is an example of how I bust an output cache in case these aren't familiar.

    using Newtonsoft.Json;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Umbraco.Core.Cache;
    using Umbraco.Core.Sync;
    
    namespace BonsaiSeed.Toolkit.Umbraco.Caching.Core {
        public class OutputCacheRefresher : PayloadCacheRefresherBase<OutputCacheRefresher, string> {
            public static readonly Guid UniqueId = new Guid("1873A3FD-FF32-43E3-A207-E91652240278");
            public override Guid RefresherUniqueId => UniqueId;
    
            public override string Name => "Output Cache Refresher";
            public OutputCacheRefresher(AppCaches appCaches) : base(appCaches) {
            }
            protected override OutputCacheRefresher This {
                get {
                    return this;
                }
            }
    
            public override void Refresh(string[] urls) {
                foreach (var url in urls.Where(x => !string.IsNullOrEmpty(x) && x != "#")) {
                    HttpResponse.RemoveOutputCacheItem(url);
                }
                base.Refresh(urls);
            }
        }
    }
    

    This logic can then be triggered across with the following command

    _distributedCache.RefreshByPayload<string>(OutputCacheRefresher.UniqueId, urls);
    

    where "_distributedCache is a DistributedCache object from Umbraco.Web.Cache. "string" can be changed to a different model, as the data passed around here will be more complex than this.

    Do note that umbraco 9 makes some changes to how this is handled with the introduction of the notifications concept. A notification can be triggered manually with

     eventAggregator.Publish(new ExampleNotification(targets, MessageType.RefreshByInstance));
    

    where "eventAggregator" is an "IEventAggregator" object.

Please Sign in or register to post replies

Write your reply to:

Draft