How to force reset cache of a query?

There is “Invalidate cache” link in the designer. But how do I do it from the code?


Hey @Dima thanks pointing this out! Right now you cannot invalidate the query cache programmatically but we’ll track this as a feature request and let you know once we ship it! This has been requested 1-2 other times, so hopefully we can prioritize this soon.

Any progress on this one? Would really help performance on some of my apps.


Hey, would love to have this kind of feature too. Something like query_name.invalidate_cache() will really helpful to boost the app performance. Thanks!

1 Like

Would love this feature as well. Have some queries cached to help the loading time of the page, but added some steps that now invalidate the cache and this would be the cleanest way to ensure the correct state.

This is a MUCH needed feature. Is there a clear timeline when it will become available? Thanks!

Hey everyone! No timeline on this feature yet, but there's an internal request for this and we'll keep this thread up to date with any new information. To any new readers of this thread, please do feel free to continue adding your +1's and context!

+1, in my case I need to invalidate the cache of some API call queries that take 5-10+ seconds to respond


Hi, I'd like to share an idea even if I have failed to apply it ...

What if you put an invariant parameter in your SQL query and change it when you want to invalidate the cache? It is a trick I used to do a while ago.
For example if you have a query like:
"SELECT * FROM users WHERE {{cacheControl.selectUsers}} = {{cacheControl.selectUsers}}"
Every time you want to invalidate the query you can do a cacheControl.selectUsers++
Also you can set the parameter as a Watched Input.

Unfortunately I tried to use it in a query in DynamoDb but I still have to find an invariant where to apply the parameter. Any suggestions?

Anyway it would be so nice to have this solved by the framework.
Thanks and good luck!

Hey everyone! Great news :tada: There's now an invalidateCache function available for queries! You can call it in a JS query, in an event handler under the "Run Script" action or as a part of the "Control query" action. Let me know if anyone has any questions :blush:


This is awsome! Thanks!

The feature works great, but does not seem to be supported in public apps (I get "Cache invalidation not supported for public apps" error message), is there a specific reason for this?

Hi @RobinLarsson! Ah, great question. We've decided not to support it for the time being. We’ve discovered that, in order to support programmatic cache clearing in public apps, we’d need introduce new public endpoints that let any user on the internet programmatically control query cacheing in Retool.