Cache dependency doesn't work

Tomasz Czado asked on April 3, 2021 11:51


I have a problem with cache dependency. Here is the code I have

ArticleViewModel loadData(CacheSettings cacheSettings)
    var result = ArticleViewModel.GetViewModel(article, _pageUrlRetriever, _attachmentUrlRetriever);

    var relatedArticles = _articleRepository.GetRelatedArticles(article);
    result.RelatedArticles = ArticleViewModel.GetViewModels(relatedArticles, _pageUrlRetriever, _attachmentUrlRetriever);

    var globalContent = _globalRepository.Get();
    result.GlobalContent = GlobalViewModel.GetViewModel(globalContent, _pageUrlRetriever);

    var dependencies = new string[]

    var relatedArticlesDependencies = CacheDependencyHelper.GetNodesDependencyCacheKeys(result.RelatedArticles);

    dependencies = relatedArticlesDependencies.Any()
                ? dependencies.Concat(CacheDependencyHelper.GetNodesDependencyCacheKeys(result.RelatedArticles)).ToArray()
                : dependencies;

    cacheSettings.CacheDependency = CacheHelper.GetCacheDependency(dependencies);

    return result;

var key = $"{nameof(ArticlePageTemplateService)}|{nameof(GetTemplateModel)}|{article.NodeGUID}";
var cacheSettings = new CacheSettings(TimeSpan.FromHours(4).TotalMinutes, key);

_progressiveCache.Load(loadData, cacheSettings);

This are generated dependencies:

  • nodes|sitename||all
  • nodeid|9
  • nodeid|3
  • nodeid|2

But when I update page that is of type, cache is not cleared.... And I don't know why.

Moreover, when I go to Debug -> Cache Items -> Live I don't see any items there but my understanding is that I should.

Recent Answers

Dmitry Bastron answered on April 5, 2021 13:36

Hi Tomasz,

The most common cause of this behavior is Web Farms not working correctly due to some reasons. Please make sure that all your web farm servers are green, there are no hung web farm tasks and the number of web farm servers you are using is covered by your license. Refer to this article.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.