DEMOS / Delayed Content

The #delay_body{} element allows you to quickly render the page and leave a placeholder for content that might be slower to load. This is particularly useful for content that is either slow to process such as querying some external API, or for greater content that might be cached, but you want user-specific content to show within the cache.

This will require a delay_body_event(Tag) function to be defined in your page module (or the delegate module if so specified) and it must handle the tag specified with the #delay_body element.

The return value of this function will be placed into the content's page.

All these delay_body_event calls are performed in serial, and retrieved via postback. If the content to retrieve is expected to be very slow, or you simply need to ensure all results are retrieved or processed in parallel then the content is recommended to be loaded with Continuations, as each continuation will update when the content is available, rather than being handled in serial.

View Module Source

Slow-Loading Content

The system time is (loading)

Working with Cached Content

Here we have some content that is being cached. At the the time this was cached, the system time was 2024-07-12 5:28:49pm. You can verify this by refreshing the page immediately, and it should roughly remain the same. But the content right here will be specific to you and you alone or is highly dynamic, so it must not be cached:

Your Session ID is: (Loading...)
The current live system time is: XX:XX:XX

Copyright © 2008-2024 Nitrogen Web Framework. Released under the MIT License.