Document Viewer Lifecycle

  • 5 minutes to read

This document provides reference information about the DevExpress HTML5 Document Viewer’s lifecycle. It explains the mechanisms behind DevExpress Web reporting, including the client-sever communication protocol and server-side report storage.

The Document Viewer’s Client-Server Communication Protocol

The HTML5 Document Viewer stores reports and performs all operations on the server. The client sends commands to initiate these operations and receives data to display. To send a command or request data, the Document Viewer sends AJAX requests to the DXXRDV.axd handler (ASP.NET WebForms and ASP.NET MVC) or the WebDocumentViewerController (ASP.NET Core) on the server. Depending on the user's actions and the current phase of the viewed report's lifecycle, these requests can specify the following commands in their payload:

Command Description
openReport Instructs the server to load a report's layout
startBuild Triggers the document creation process (the report's CreateDocument method is called). The report creation process is carried out in a background thread. This command is sent when a parameter is submitted, a drill-down detail region is opened/closed, and sorting is applied.  
getBuildStatus Checks on the document creation progress. The client sends this request multiple times before the document is created. The client updates the progress indicators based on the server response. 
getDocumentData Loads the created document's metadata after the document is created.
getPage A GET request that loads a document page's layout data (bricks and image). This request can be executed after the getBuildStatus request is executed for the first time to load data for a page that was created. This request is also executed after the zoom factor is changed to load a suitably sized image. 
close A request to close a document or a report and generated document when the Close method is called on the client.

A browser's developer tools provides information on how and when the viewer sends these requests to communicate with its server side.

How Reports are Stored

Report Definitions and Report Documents

On the server, every report is stored in the following fundamental states:

  • A report layout definition - A report layout without data.
  • A report document - A document built from a layout definition. A report document can be rebuilt multiple times.

Refer to the Store Report Layouts and Documents documentation section for more information.

Caching Mechanisms

Report layout definitions and generated documents are cached on the server side. The Document Viewer uses two caching levels:

  • A short-time Cache - This is the fastest cache that ensures that frequent operation are always fast, its Time to Live resets with every request. The Cache stores report layouts and documents in their object representation.
  • A Storage - A long-time cache that can be configured to serialize the cached data and temporarily unload it to the file system or Azure Cloud Storage.

Report Lifecycle

A report's lifecycle begins when the server calls the OpenReport method. This method call produces an XtraReport instance and saves it to the In-Memory Cache and Storage. The animations below illustrate the major stages of a report's lifecycle.

NOTE

In the demonstrated lifecycle, the Storage is configured to use the file system or Azure Cloud Storage. In in-memory mode, the Storage and Cache are cleared simultaneously.

The Time to Live for cached report layouts and documents can differ depending on how the CacheCleanerSettings and StorageCleanerSettings are configured.

The steps below illustrate the full lifecycle:

  1. [Server] The OpenReport method is called to load a report’s layout definition (REPX), the loaded layout is put into both the In-Memory Cache and Storage.
  2. [Client] The client-side UI is rendered on the web page.
  3. [Client] The viewer sends the startBuild HTTP request.
  4. [Server] Report document creation process is started. While this process is running, the generated document’s data (PRNX) is temporary stored in the Cache.
  5. [Client] The viewer sends a getBuildStatus HTTP request.
  6. [Server] The server responds that the document is still being generated, but the first few pages are ready.
  7. [Client] The viewer sends the getPage request to get the created page's data.
  8. [Server] The document creation process is complete. The generated report's document (PRNX) is saved to storage.
  9. [Client] A getBuildStatus request is sent. The server responds that the document is ready and all its pages are available.
  10. [Client] A getDocumentData request is sent.
  11. [Server - 1 minute later] The client did not request the report document’s data during this time, so the server removes this data from the In-Memory Cache.
  12. [Client] A getPage request is sent when a user scrolls the document to a new page.
  13. [Server] The server loads it to the In-Memory Cache again when the client requests the document data.
  14. [Server - 1 minute later] The report's document is cleared from the In-Memory Cache.
  15. [Server - 2 hour later] The report's document is cleared from Storage. The report's layout data is cleared from In-Memory Cache and Storage.

Note that if the report was opened from a report URL, the report layout can be restored after this report layout is removed from Storage (2 hours).