Content Cache dependency in Kentico V9

Reshma K asked on July 1, 2020 11:26

I want to update cached content of one custom table when another custom table item is updated. Let's say I have two Custom Tables: Product and Order. There are List and Edit pages for both Product and Order.

In DB there is a trigger on Product that updates some data on Order when any product is modified.

My scenario is, when I update lets say any product from UI, I want cached orders to refresh and reflect changes made in DB for them. This is not happening right now.

Global settings are 10 minutes for content caching. But somehow it takes 20 minutes to reflect changes. Not sure why. Also on Orders' CustomTableRepeater's System Settings->Cache minutes is set to 0 means it should not be caching content at all but it still does so I am at loss here

Answer to this scenario would be setting cache dependency dummy key as per Kentico documentation.

My questions are:

  1. Do I set dependency key of type Order to Product's edit page's web part partial output cache dependency property? for e.g. orders|all

Will this refresh all orders cached in for orders' custom table data source when any Product is modified?

  1. Or I set dependency key of type Product on Orders' repeater's System settings->Content Cache Dependency property? for e.g. products|all

Please note Cache minutes property is set to 0 so ideally this content should not be cached.

  1. Or add above key to Order's Edit page's webpart's partial output dependency?
  2. Also for custom table how to get proper dummy key? Is it

products|all

OR

nodes|corporatesite|products|all

OR

customtableitem.products|all

Or I need to add pages' dummy keys that I can see in debug->cache settings?

I have tried setting up all these things but nothing seem to work. Any help is greatly appreciated.

Correct Answer

Reshma K answered on July 28, 2020 07:08

I was able to resolve my issue. Putting answer here for future reference I will first list down what I tried: 1. Update Hotfix 2. Add Partial Cache Dependency key 3. Add Cache dependency key for Content caching. Nothing worked.

Got an idea by reading answer from this questions: https://devnet.kentico.com/questions/kentico-8-2-database-caching

When I was updating CustomTable A's data, in DB trigger on A would update data in table B which I needed to refresh in Site's cache.

When I tried 'Clear Cache' from Debug application from Admin, it still did not update data in Site. Also my Custom Table data in Admin was also not getting updated.

So reading one answer from above question, I realized I need to refresh Hashtables for data to be refreshed in admin and subsequently in site.

So I added code to CustomTableForm.aspx.cs in OnAfterSave event handler. Here I am checking if current CustomTable is my table A, then refresh hashtables of B.

This worked.

0 votesVote for this answer Unmark Correct answer

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