Skip to content

Blazor InteractiveServer takes twice as long to create a page #53501

Closed
@DavidThielen

Description

@DavidThielen

Hi all;

First off, this is the wrong category for Blazor issues, please tell me the proper location.

Second, while there is great documentation about how InteractiveServer works and is used, there is almost none about why you all took this new approach. The best I got was this discussion.

As I understand it the goal is twofold:

  1. Get something up ASAP so a user does not get bored and leave the page.
  2. Get the complete static page up ASAP for crawlers.

These are both great goals. Unfortunately InteractiveServer mode will call OnInitializedAsync() twice, sometimes. This means reading the data to populate the page has to be done twice. And this means it takes twice as long to have the static web page delivered. And because this happens sometimes, you can't even write code to do the fast activity the first call and the slow (calling the DB) the second call.

As this is counter to the two goals listed above (please correct me if those are not the goals that drove InteractiveServer), I believe that this double call should be viewed as a bug and fixed.

As an alternative, you could consider instead having three calls, each called exactly once:

  1. OnInitializedFastPartAsync
  2. OnInitializedEverythingElseAsync
  3. OnTwoWayCommunicationEstablishingAsync
  4. OnTwoWayCommunicationEstablishedAsync

I'm not really sure if you need the third and/or fourth one. But breaking the initialization into two calls, each of which is called exactly once, would eliminate the present issue where pages take twice as long to load.

But at a minimum, please eliminate the sometimes second call to OnInitializedAsync() - doubling page load times is really bad.

thanks - dave

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.area-blazorIncludes: Blazor, Razor Componentsquestion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions