External application caching

John Martin asked on January 8, 2019 22:41

Hey everyone. I am developing an Web API 2 application (external) which used Kentico (11) libraries (content receiving, media library). I have some problem with kentico caching.

I used providers to get content from Kentico and repositories (same as in DancingGoat app). But when i cache my data with dummy key (nodes|webapi|custom.article|all), and then change some custom.article in Admin Interface, my external application doesn't know that needs to update cache. Also, i have not see cache objects in Debug->Cache object.

How can I implement data caching in my external app? Is web farm responsible for this? (If yes, how can i config web farm for external app?)

Thank you.

Recent Answers


Peter Mogilnitski answered on January 8, 2019 23:02 (last edited on January 8, 2019 23:12)

Because your api application and kentico are 2 different processes(perhaps even servers). If you reset cache in one process the other one does not know anything about it.

1 votesVote for this answer Mark as a Correct answer

John Martin answered on January 9, 2019 08:33

Thank's for answer. But how can I solve this issue in my situation?

1 votesVote for this answer Mark as a Correct answer

Lukáš Gancarčík answered on January 9, 2019 14:24

As Peter mentioned, the reason is that Kentico Administration and MVC are two separate applications - I would recommend to use Glimpse (https://www.nuget.org/packages/Kentico.Glimpse/) for cache debugging in MVC application.

You can find general information how to setting up Glimpse in MVC application here: https://docs.kentico.com/k12/developing-websites/troubleshooting-websites/debugging-sql-queries-with-glimpse-on-mvc-sites

1 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on January 9, 2019 15:30

Essentially one app has to notify another app about some changes. I'd say the straight forward solution would be to attach to a global event like "document update after" in your kentico admin and send notification to you web api app "cache controller" (that you need to create) to say "hey this document has changed". In your controller you can "touch key" for this particular document or reload all document of this type etc.

P.S. you can always choose not to use dependencies i.e.cache everything for example 10 minutes.

I dont know your situation so it is hard to comment.

1 votesVote for this answer Mark as a Correct answer

Zach Perry answered on January 9, 2019 16:00

If you set up your web api like the normal MVC projects, and set up web farm, it should sync the clearing of the cache. You will have to make sure you set up your web api application correctly tho.

1 votesVote for this answer Mark as a Correct answer

John Martin answered on January 9, 2019 19:35

Thank's for answers.

Lukáš Gancarčík, how can I config web farm for external application (Web API 2)?

Peter Mogilnitski, nice idea. Thank's, i'll try. But how should i deal with document relationships?

Zach Perry, nope. It's separated Web API 2 app. Can i set up web farm without using MVC?

1 votesVote for this answer Mark as a Correct answer

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