Cache clear hook?

Is there an event (hook (e.g. pages.cache.flush:after) or some other way) that fires when the panel flushes the cache (happens after altering content via the panel)?

I have a custom cache which I’ld like to flush too when that happens.

Thx!

No, I don’t think so, you would have to set up your own hooks that flush the cache.

I want to do so, but hook into what then?

Hooking into all hooks about page, site, et sounds a bit greedy to me tbh?

Edit: should I create an issue on github asking for a pages.cache.flush hook?

Hm, the question is why you want to make your cache dependent on when Kirby flushes the cache. Maybe you can use some more intelligent logic, or the Kirby lapse plugin?

Yes, why not?

When you have custom caches that are built from content. As soon as the content changes (== the moment when kirby panel flushes the pages-cache), I’ld also like to invalidate my custom cache so it can be rebuilt reflecting the potential changes that might have happened to the content. Unless there is a better way?

I don’t know your exact use case and can’t tell if there is a better way. I think the Kirby cache is quite brutal in that it flushes the whole cache no matter what. It might make sense to also flush your cache when Kirby does, but often the purpose of a custom cache is to fine tune caching a bit more.

E.g. I have many products on a website (in multiple languages). The standard pages cache is enabled on the overview page, but since faceted navigation is also on there, it takes a while to build all the many different potential queries. The products are also needed in site-wide things like search.

I try to be clever and set up a collection for that, but since that only creates a “shortcut”, I’ld also like to take advantage of caching there. Then no need for roundtrips to the file system is necessary to assemble the products (e.g. in search, or in the facet-navigation products overview page).