Which API endpoint to refresh questions' cache

Hi there !

Which API endpoint should be used to refresh questions’ cache ?

Use case :
I am creating dashboards on data that is rarely updated (at most every day). Dashboard queries take 1-2 minutes on the whole dataset, which is way to long for users. But I cannot pre-compute results in the database, as I need filters on the data (and questions only take ~100ms with filters).

I set cache with a minimum query duration of 1s and TTL multiplier of 100000. This way cache will be used for almost every question.

Now I need to refresh this cache when data is updated (or before it expires).

So the question is : which metabase API endpoint should be use to trigger questions’ cache refresh ?

Thanks for your help !

1 Like

I’ve not tried this, but what about:

I think you need to click the link to see the actual API doc

Thanks a lot ! I did not see this ignore_cache option.

However, it does not work, as the Refresh button does not work either when cache is active… There is already an issue about this https://github.com/metabase/metabase/issues/7282

I tried to deactivate caching, run the query, then activate caching again, but the old cache value is not cleared nor updated.

I found this hacky workaround to update cache before the issue get solved :

  • set query-caching-ttl-ratio to 1 (PUT /api/setting/query-caching-ttl-ratio)
  • wait until queries’ cache expire (3 minutes is okay in my case)
  • run all queries (POST /api/card/:card-id/query)
  • set back query-caching-ttl-ratio
2 Likes