InvenTree icon indicating copy to clipboard operation
InvenTree copied to clipboard

[PUI] Reduce duplicate queries

Open SchrodingersGat opened this issue 1 year ago • 4 comments

Platform interface currently performs a number of duplicate API queries which slows down page response time.

image

SchrodingersGat avatar Jul 09 '24 09:07 SchrodingersGat

We could define some small amount of caching time in tanstack query. That way when the same query is performed multiple times in the loading process, only the first is send to the server.

wolflu05 avatar Jul 09 '24 10:07 wolflu05

@SchrodingersGat could this be the permission check page? I have various issues with multiple requests since that merged

matmair avatar Jul 09 '24 10:07 matmair

@wolflu05 How would this cache be invalidated once things change because of a query? Is there a mechanism for that?

matmair avatar Jul 09 '24 10:07 matmair

I have various issues with multiple requests since that merged

Me too. I think Oliver is already working on a fix in #7598. Hope that gets merged soon.

How would this cache be invalidated once things change because of a query? Is there a mechanism for that?

We could set the (frontend) caching to a small time like 1s to 5s and also invalidate the entries after the user creates or updates something. Since we have all in generic components, that shouldn't be to hard. There is documentation for invalidation here. Detailed documentation for how caching works can be found here.

wolflu05 avatar Jul 09 '24 10:07 wolflu05

This has been largely addressed, enough that I am happy to close out this issue. Will continue to monitor for any query issues

SchrodingersGat avatar Nov 11 '24 06:11 SchrodingersGat