Headless KQL Queries Cache

Hi,

i am using Kirby in a headless setup with a static build page via Astro JS as the frontend framework. I have some dynamic parts in the page implemented as Vue Components in so-called Astro Islands.
One of these Vue Components fetches data via a KQL Query. The data requested are Virtual Kirby pages based on a .csv-file on the server. The .csv-file gets updated frequently and the data fetched of course should be up-to-date, but sometimes is not. The data are daily meals for a cantine which show up on the website.
I’ve setup the Kirby Cache to ignore the page type “meal” generated from the csv. What i still have in my “storage->cache”-folder are a lot of files called "query-somerandomhash.cache which contain data regarding the “meals”.

How do i disable these query-caches?

I am aware the problem could also lie somewhere else in the setup with the csv-file and the server-filesystem and all but for now these cache-files are my biggest hint.

In case anybody else stumbles across this.
From the research i did now it seems like KQL uses the standard kirby pages cache but since it does not actually render a page the ignore option is not even triggered and therefore has no impact.
Building a custom “no-cache” kql route where i disable the kirby pages cache temporarily for each request seems to work.
So within my route action i have this code:

$input  = kirby()->request()->get();
$oldActive = kirby()->option('cache.pages.active');
kirby()->option('cache.pages.active', false);
$result = Kql::run($input);
kirby()->option('cache.pages.active', $oldActive);

return [
 'code'   => 200,
 'result' => $result,
 'status' => 'ok',
];

I am only using this specific route for requests where i don’t want any kind of cached results and it seems to work fine. No more .cache files for these queries generated.

Since i am still relatively new to Kirby maybe anybody who has a look at the code can identify anything considered bad practice or has any advise on improvements?

What I’m wondering is if caching shouldn’t be disabled in Kirby anyway, and any caching done client side, see also Caching strategies - Building Modern Websites with Astro | StudyRaid.

Another frontend library, but maybe also helpful: useKql | Nuxt KQL

Thanks for the link. Great read and some info i didn’t know about Astro.

It seems to me though the Kirby cache is working fine for my setup with KQL, Astro and the static build mode. Changes via the panel flush page caches so while pages have no changes the kql queries from astro get answered quickly based on the cache files leading to a nice and fast build process.

Of course this falls apart with the parts of the frontend where i don’t want to rely on cached data which is the case for the virtual pages from the csv file. Thus my question on how to disable cache for those pages.

Can you describe a detailed scenario where the Kirby Cache interferes in a way that it should be disabled?

No, not that I know of, and I am by not means a frontend dev. I was just thinking that if you do caching on the frontend, that would prevent unnecessary calls to the backend, so provide better performance. Plus you don’t have to resort to this workaround to disable the cache.