CodeSharePaul
07/27/2023, 9:26 AM<cache>
tag helper to be invalidated on publish and I found @Warren Buckley and @marcemarc's <our-cache>
tag helper which i like the look of. https://our.umbraco.com/forum/using-umbraco-and-getting-started/109868-how-to-clear-the-cache-tag-helper-programmatically-in-aspnet-core-using-contentcacherefreshernotification#comment-340478
The only thing I have found is that when I am testing out the cacherefresher notification to log when it fires, in a single site with no load balancing, it doesn't log anything at all, meaning it's not hitting that event at all. Does this mean that this won't work for non load balanced environments or does it mean that event doesn't fire in dev or something else?Warren Buckley
07/27/2023, 9:51 AMMatt Wise
07/27/2023, 9:54 AMMatt Wise
07/27/2023, 9:55 AMCodeSharePaul
07/27/2023, 10:17 AMWarren Buckley
07/27/2023, 10:27 AMWarren Buckley
07/27/2023, 10:27 AMWarren Buckley
07/27/2023, 10:34 AMWarren Buckley
07/27/2023, 10:34 AMCodeSharePaul
07/27/2023, 10:58 AMWarren Buckley
07/27/2023, 11:41 AMCodeSharePaul
07/27/2023, 3:41 PMCodeSharePaul
07/27/2023, 3:41 PMCodeSharePaul
07/27/2023, 3:42 PMcs
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
namespace MyProject.NotificationHandlers;
public class CacheRefresherNotificationHandler :
INotificationHandler<ContentCacheRefresherNotification>,
INotificationHandler<DictionaryCacheRefresherNotification>,
INotificationHandler<MediaCacheRefresherNotification>
{
private readonly ILogger<CacheRefresherNotificationHandler> _logger;
public CacheRefresherNotificationHandler(ILogger<CacheRefresherNotificationHandler> logger)
{
_logger = logger;
}
public void Handle(ContentCacheRefresherNotification notification)
{
_logger.LogInformation("Content Cache Cleared");
}
public void Handle(DictionaryCacheRefresherNotification notification)
{
_logger.LogInformation("Dictionary Cache Cleared");
}
public void Handle(MediaCacheRefresherNotification notification)
{
_logger.LogInformation("Media Cache Cleared");
}
}
CodeSharePaul
07/27/2023, 3:42 PMcs
using MyProject.NotificationHandlers;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Notifications;
namespace MyProject.Composers;
public class RegisterNotificationHandlersComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.AddNotificationHandler<ContentCacheRefresherNotification, CacheRefresherNotificationHandler>();
builder.AddNotificationHandler<MediaCacheRefresherNotification, CacheRefresherNotificationHandler>();
builder.AddNotificationHandler<DictionaryCacheRefresherNotification, CacheRefresherNotificationHandler>();
}
}
CodeSharePaul
07/27/2023, 3:44 PMContent Cache Cleared
If I save a media item it logs Media Cache Cleared
And if I save a dictionary item it logs Dictionary Cache Cleared
CodeSharePaul
07/27/2023, 3:45 PM<our-cache>
tag helper and it has helped me understand umbraco a bit more.