Multiple dummy cache keys

Aaron Macdonald asked on November 2, 2022 08:38

Hello

The documentation does not seem to explain how to set multiple cache dependencies, and we have a particular requirement for it.

As a simplified example say we have MVC output caching enabled, and we want a controller action's output cache to depend on two different pages with dummy keys:

  • node|mysite|/path1/page1
  • node|mysite|/path2/page2

Can we combine these with something like comma separation as in the following?

  • node|mysite|/path1/page1,node|mysite|/path2/page2

If not, then we'd much appreciate an explanation for how this can be done.

Correct Answer

Aaron Macdonald answered on November 3, 2022 01:57

The simple answer in this case was that there are overrides:

  • HttpContext.Response.AddCacheItemDependency
  • HttpContext.Response.AddCacheItemDependencies

Recommend adding a note to this page:

https://docs.xperience.io/configuring-xperience/configuring-caching/caching-on-mvc-sites#CachingonMVCsites-Cachingtheoutputofcontrolleractions

0 votesVote for this answer Unmark Correct answer

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