Access control
When I use accessControl the menus are taking a lit bit longer to render.
2 Replies
Hi @Sly. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
You're right to notice that using access control can affect the rendering time of menus in refine. This is a known behavior, and there are ways to optimize it.
The reason for this delay is that refine checks access control for each resource when rendering the menu items. As the number of access control checks increases, it can impact the performance, especially if these checks involve remote endpoints Access Control Provider Performance (https://refine.dev/docs/authorization/access-control-provider/#performance).
To improve the performance, you can use caching for the access control checks. Since refine uses react-query, you can easily configure the
staleTime
and cacheTime
properties. Here's an example of how you can do this:
By default, refine uses 5 minutes for cacheTime
and 0 minutes for staleTime
for its own access control points Access Control Provider Performance (https://refine.dev/docs/authorization/access-control-provider/#performance).
If you're still experiencing significant delays, you might want to consider optimizing your access control logic or fetching available menu items once and using a cached version, as this can reduce the number of access control checks needed Github Issue Comment (https://github.com/refinedev/refine/issues/6486#issuecomment-1478061383).
Remember, the exact impact on performance can vary depending on your specific implementation and the complexity of your access control logic.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1172098337760096258> Kapa.ai is still learning and improving, please let me know how I did by reacting below.