For repeatedly-used elements, cache JSON definitions in the browser #4794
Replies: 3 comments 3 replies
-
Wishful API endpoints:
In both cases, the endpoint is not hit for data, if it is found in Points to note:
|
Beta Was this translation helpful? Give feedback.
-
Actually there is no need to ask the server again. The browser can include the cached components that it have + the hash of it somewhere in the request (cookies I'd imagine) and the server can act accordingly, serving placeholders if browser have + it is up-to-date, or the actual content if not. |
Beta Was this translation helpful? Give feedback.
-
Interesting observation, @evnchn. But I'm not sure how this can work in general. Anyway, when looking into the network traffic to see what amount of data we're talking about (~30KB), I noticed that search_index.json is around twice as large (66KB) and isn't cached at the moment: ![]() Even though this is not the point of this feature request, there might be lower hanging fruits for reducing traffic. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
So, the NiceGUI site felt more sluggish, after the navigation hierarchy was introduced in #4732
To visualize, the yellow region is the data which is served exclusively for rendering the sidebar and the hierarchy:
(Search
{"id":"
to show this)By my count, it accounts for 30% of the page's content data. Not a negligible amount.
I wonder if it is possible to cache the below in the browser to avoid retransmission. Point 1 is specific while point 2 is more generic
nodes
list passed intoui.tree
, can we cache it? (potentially for other elements which expect one bigoption
, likeui.aggrid
, and that remains mostly constant from load to load)_to_dict
. Provided that the element is exactly the same between page visits (or at least you can render a constant element, and then make modifications to it later after the client has connected), can we cache that?Beta Was this translation helpful? Give feedback.
All reactions