Skip to content

[Blazor] Bring back stateful prerendering #15317

Closed as not planned
Closed as not planned
@javiercn

Description

@javiercn
  • We used to have stateful prerendering where we would render the components on the initial circuit, produce static HTML for it, and keep it around until the client reconnected to it.
  • This provided a very nice model as we would avoid having to render the app again when the client connected to it and it would preserve the work generated during prerendering.
  • The main issues we had with this approach are two:
    • We had to keep the app in memory to guarantee that the client could reach it.
    • MVC and Server side blazor were forced to share a contract as server-side blazor needed to be able to replace the rendering capabilities of MVC for rendering interactive components.

Considering the first issue the most important one, we could bring back a modified version of this feature as follows:

  • Stateful prerendering is an enhancement over the existing server-side rendering support.
    • We would serialize the parameters to HTML as we do today in the descriptor.
    • We would include the Circuit ID for the associated circuit.
    • Upon the browser starting up, we would try to re-connect to the existing circuit first.
      • If that worked, the app would resume from there.
      • If that didn't work, we would start the circuit from scratch.
  • The server keeps a limited pool of prerendered circuits around for a very limited (configurable) set of time.
    • The pool is FIFO, if it gets exhausted the oldest prerendered circuit gets cleaned up.
    • If a client tries to reconnect and fails, then it simply starts a new instance with the original serialized parameters.

At this point the feature becomes an enhancement over the current experience, under regular load conditions the feature saves work and bandwidth on the server by avoiding things like requesting data from services multiple times or duplicating the amount of render requests, and under heavy traffic the feature simply falls-back to the current prerender mode.

Some supporting issues associated with this are #15266 #13607 #14977 #13448

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-allThis issue impacts all the customersarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-blazor-serverfeature-blazor-server-experienceIssues that make Blazor server experience different of Web assembly or Desktopfeature-prerenderingIssues related to prerendering blazor componentsseverity-majorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions