Switch from Static render mode to Interactive when Edit mode #4473
-
I noticied that managing pages with a lot of modules in static render mode is quite slow as it requires several enhanced navigations, which basically means all the modules are loaded again in the server and sent back as html with the overhead this supposes. Therefore, I was wondering if it would be possible/wise to have a mechanism where static modules are made interactive when the user has logged in and has edit permission on the page/module (perhaps only in server mode, not wasm?). In this way, for example, the Action Dialog to delete modules would be interactive instead of with form submissions, and the same applies to switching to edit mode. And also, you already have a SignalR connection opened for the interactive control panel and the site is interactive so you wouldn't be crossing any render mode boundaries anyway. Any thoughts or comments about this idea? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
@mdmontesinos have you tested this with the 5.2.0 release? One of the main areas of focus in 5.2.0 was related to performance/scalability - specifically the UI scenarios which cross render mode boundaries (ie. Module Actions Menu, Control Panel) were optimized in the release. To elaborate on this a bit further, every single component in a page is treated as an independent UI element by Blazor. So let's say you are using static rendering for your site and you have 10 HtmlText modules on a page. By default the page will be fully rendered statically. However when you login as an Admin and enable Edit mode, all of the "interactive" features will be activated. This includes the Control Panel which is an interactive component. It also includes the Module Actions Menu which is rendered for each module instance - so 10 interactive components in this scenario. As part of the Blazor rendering process, there will be 11 different components which need to cross the render mode boundary from static to interactive. Each of these components have state which is passed as parameters. This usually includes the standard Oqtane state objects for PageState and ModuleState. In each of these cases the state which is passed as parameters to a specific interactive component will be serialized/encrypted into the page output, as this is the way that Blazor handles render mode transitions. So if the serialized/encrypted size of a PageState object is 50KB then you will have 550KB of "viewstate" injected into your page output (as you have 11 interactive components). Based on this example, you can see how this can very quickly become a major problem. In the scenario I just described there were only 10 modules on the page... however imagine a static module with a grid control where some of the elements in each grid row are interactive components (ie. ActionLink, ActionDialog) - in this case the number of individual components with render mode boundaries would be much higher resulting in massive viewstate. I actually had an example where there was 4.2MB of viewstate being injected into a page! The solution in 5.2.0 was to trim the size of the parameters as much as possible to reduce the amount of viewstate. The other solution is to try to reduce the number of render mode transitions ie. by avoiding mixing render modes, or by reviewing the functionality and if you have a lot of interactive components in your UI then make the parent component interactive as well. |
Beta Was this translation helpful? Give feedback.
-
@mdmontesinos looping back to this item... the original thread contains a suggested solution for dealing with interactivity with Static render mode, but it never clearly outlines the actual problem and how to reproduce the issue. Based on the last post I am guessing it has something to do with the ActionDialog component in Static render mode - but it is still not clear. If you are able to elaborate it would be helpful. |
Beta Was this translation helpful? Give feedback.
@mdmontesinos it sounds like you are trying to mix different use cases within the same module component. Generally it is better to separate those concerns into different components. For example your Index component would be static and display the carousal. It could contain a single Manage button which becomes visible when you go into Edit Mode. Clicking Manage will display the Manage component which is interactive and contains a grid and allows management of individual items. This clearly separates the front-end (view) from the back-end (admin) and allows you to employ the appropriate render mode for each scenario.