Page Rendering
Structr doesn’t store pages as simple text files but rather as connected nodes in the database that make up the DOM tree.
Together with the page elements (tags), there’s a lot of metadata like conditional attributes, access rights and visibility settings stored in the database which are difficult to export to a single source file. Furthermore, there are resource files like CSS, JavaScript or images linked to some elements like <a>
, <link>
, <script>
, <image>
etc., and they are also connected in the underlying graph database and managed by Structr.
When rendering a page, the page engine starts by looking for a page matching the name or the page’s path attribute. If found, Structr starts a traversal along specific relationships between the page and its elements.
For each node, the metadata are being evaluated to decide whether or not to include a node in the rendering or skip it.
While running through the page graph, the engine collects the data from each node and appends it to the output buffer which gets pushed to the browser client. By pushing the output to the client asynchronously, the browser can start displaying a page even before the server-side rendering has not finished.
The page traversal is very fast. A typical page is created in less than 100 ms on the server.