updateContent()

Updates the preloaded content to the currently published content.

Scrivito’s prerendering improves the loading speed of your web application. To prerender your pages, the app uses the currently published content to generate a preload dump for the first meaningful paint, which is then replaced on-the-fly with the JS-enabled version. However, with rapid changes to the published content, the previously generated dump may become outdated, which may cause the pages to not include the latest content updates. To remedy this, Scrivito.updateContent is available. If called in the app’s startup phase, the preloaded content gets updated, bridging intermediate publishes.

Note that hydrate will not operate successfully if updateContent is executed before hydrate has finished.

A call to updateContent has no effect if no preload dump exists.

Returns

[New in 1.34.0]A Promise that resolves once the content update is complete.

Remarks

Updating is done at best effort: If the preload dump is severely outdated, Scrivito may be unable to update all or parts of the content.

Examples

If the application supports ReactDOM.hydrate, the initial render could be implemented as follows:

If the application does not work with hydrate, the following would be an implementation that uses the content data from the dump but additionally updates it to the newest published content: