Try our conversational search powered by Generative AI!

Detecting When Cache Changes?


Hi all, 

I'm trying to maintain a hash table of episerver page ids to domain specific ids. The hash table uses the singleton pattern and is initially populated by running through the full list of pages. This mapping will need to be recreated however everytime the cache changes, say for example if a new piece of content is published. 

My touble is I can't seem to find a way of detecting when the Episerver cache changes. No such change event appears to exists on the EPiServer.CacheManager class.

Does anybody have an idea of how I might detect such a cache change in episerver?



Jan 20, 2014 13:10


I'm assuming you're using EPiServer 7<.

If you only need to update the list when content is published, you can listen to content repository events:

namespace DV
    using EPiServer;
    using EPiServer.Core;
    using EPiServer.Framework;
    using EPiServer.Framework.Initialization;
    using EPiServer.ServiceLocation;

    public class EventsInitialization : IInitializableModule
        private bool eventsAttached;

        public void Initialize(InitializationEngine context)
            if (!eventsAttached)
                 var repository = ServiceLocator.Current.GetInstance<IContentEvents>();

                repository.PublishedContent += this.PublishedContent;

                eventsAttached = true;

        public void Preload(string[] parameters)
            throw new NotImplementedException();

        public void Uninitialize(InitializationEngine context)
            repository.PublishedContent -= this.PublishedContent;

            eventsAttached = false;

        private void PublishedContent(object sender, ContentEventArgs e)
            // Do your magic here.


Jan 21, 2014 2:20
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.