Cache dependency and filter

Wei Wang asked on January 19, 2022 21:47

Hi,

I have a webpart that includes a filter. When I added cache in the web part control's code, the filter won't work if I select a different location. I don't know what to add for the cache's dependencies since it's not an object, it's a dropdown list of locations which is based on a page type. How can I add dependencies to a page type or a query or a transformation?

This is Kentico 11 portal engine.

thanks, Wei Wang

Recent Answers


Juraj Ondrus answered on January 20, 2022 08:52

What cache are you using? Isn't it possible that you are caching the whole page output?

0 votesVote for this answer Mark as a Correct answer

Wei Wang answered on January 20, 2022 13:43

Partial cache dependencies on the webpart. Custom Code is following this example:https://docs.xperience.io/k11/custom-development/caching-in-custom-code

but I don't know what to put for the cache dependencies.

How do I cache the whole page output? If the webpart filter changes, the output should change.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on January 20, 2022 13:45

Why are you caching the filter web part? It does not make any sense to me. What do you want to achieve with that?

0 votesVote for this answer Mark as a Correct answer

Wei Wang answered on January 20, 2022 13:52

I want to cache the webpart, it's a calendar list of events. Filter is just happened to be on the webpart with dropdown locations selection. But the page loads to slow when no location is selected. Sorry I don't know much on caching. I just want the list of events to be in cache unless location changes. But I can't find how to add this trigger in the cache dependency. Maybe use page cache?

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on January 20, 2022 14:18

OK, so it is a custom web part displaying something. In this case, I would rather redesign the web part and optimize its code to act faster. Adding caching here will not help much since the data are dynamic so you will be losing time and performance by flushing the cache every time the selection changes - makes no sense to use caching here. I would rather look what could be optimized when loading the data - e.g. load just the columns you are displaying in the list, etc.

0 votesVote for this answer Mark as a Correct answer

Wei Wang answered on January 20, 2022 14:22

ok, thank you very much

0 votesVote for this answer Mark as a Correct answer

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