(Bug) invalidateCache does not invalidate cache

  • Goal:
    We have a heavy query that I'd like to implement caching for. I have the Advanced settings for the query togged to cache the results for 300 seconds.

I also have a button with an event handler that is set to clear the cache:
image

Clicking this button triggers the invalidateCache and a notification that the cache was successfully cleared:
image

But, refreshing the table multiple times, the results continue to be pulled from cache:
image

And, checking the state logs, my the query's servedFromCache stays true despite multiple cache clearing. The only time it returns false is after the 300 seconds elapse.
image

  • Steps:
    I've read almost every post about caching issues and can't find a solution.

Also constructed a separate javascript query to invalidate the cache; it also doesn't work:
image

1 Like

Hi - I'm having the exact same issue, any help would be appreciated thanks

Thank you for bringing this issue up. I have sent a bug request over to our team to checkout.

@MaximeD I got a tip to duplicate the app, and that fixed the caching issue for me.

There's an option to do this easily by clicking the 3 dots in the top right (in editor view) and selecting "Duplicate app"

1 Like

Thank you for pointing this out

Thanks to @Harry_Doan this should now be fixed on v3.41.0 on Cloud (current version of cloud) and self-hosted stable release v3.33. :rocket: :white_check_mark: Related topic.

1 Like

I noticed that with invalidateCache() it doesn't work.

This doesn't work also:

await getRows.invalidateCache;
await getTotalRows.invalidateCache;
// or 
await getRows.invalidateCache();
await getTotalRows.invalidateCache();

I made a javascript query for this code above. Only thing that works is the 3 dots on the getRows resource and invalidate the cache there. Seems caching is buggy. I have not yet got it working in any of my projects.

I'm on cloud so I should have this bug right?

Hi @Steven_W,

Can you share of screen shots of a cache before and after calling the .invalidateCache() method?

From the thread that Kayla linked, it seems that the issue was occurring when users were working on versions of the app that were not the most recent.

Additionally users found that after the patch to fix this they were able invalidate caches using the triple-dot query option on the Code drawer (Cmd+Shift+M on Mac), the left sidebar in the query list (also in a triple-dot menu), and finally programmatically via a query's .invalidateCache() method.

If you are on cloud you should definitely not be having these issues. If you can share more details on the resource/query being used when encountering this issue along with screen shots that would be very helpful for us to share with the engineering team to fix this!

I shared them here:

I use a retool database query on retool mobile.

1 Like

Ahhh ok I see, thank you for sharing that!

It sounds like Darren was able to reproduce this issue and likely filed a request to our engineering team to fix it.

Will report back with any news and apologies for the inconvenience :sweat_smile:

Our team is facing similar caching issue. We are trying to generate unique auth header (and date header) using a transformer - but every time we invalidateCache and trigger the transformer to get an unique .value from it, we do get cached value. We're using self hosted retool.

Eagerly waiting on any update on the fix for invalidateCache.

1 Like

On mobile right? Or is this on desktop?

Hello @ArunSriniv,

I think that you might be able to fix this by moving your logic from a transformer to a JS Query block.

Transformers are primarily used for creating new return values from data and might not have the necessary scoping to alter a query's cached state/data.

However I believe that a JS Query should be able to execute . invalidateCache as properly.