Skip to main content
A newer version of this page is available. .

Document Hibernation

  • 2 minutes to read

Overview

At the server DocumentManager object level, DevExpress office controls provide the capability to automatically free the server operative memory (RAM) by hibernating inactive open documents. By default, document hibernation is disabled.

If you enable document hibernation, open documents that were idling for a certain time will be released from server memory and saved to the server file system at a specific path. This reduces server memory consumption and prevents the loss of unsaved document changes even if planed IIS process recycling occurs.

API

The following hibernation settings are available through the API exposed by the DocumentManager object.

Property Name

Description

DocumentManager.EnableHibernation

Switches the hibernation functionality on or off. The default value is false.

DocumentManager.HibernationStoragePath

Specifies the path to the server directory to which open documents are hibernated after idle timeout expiration.

DocumentManager.HibernateTimeout

Specifies the idle timeout for documents. The default value is TimeSpan.FromHours(1).

After this timeout has ended, if an end-user starts interacting with a hibernated document, the document is restored from the file back to the server’s RAM. Note that the Undo/Redo history is the only data that is lost after a Spreadsheet timeout (a RichEdit document’s Undo/Redo history is stored on the client-side).

DocumentManager.HibernatedDocumentsDisposeTimeout

Defines the timeout specifying how long hibernated documents are stored on the server before disposal. The default value is TimeSpan.FromHours(24).

After this timeout has passed, a document file stored in HibernationStoragePath will be completely deleted of and all unsaved end-user document changes will be lost.

DocumentManager.HibernateAllDocumentsOnApplicationEnd

Specifies whether or not all open documents should be hibernated.

It is recommended that you define hibernation in the Application_Start handler in Global.asax. In this case, even after a server fails, you are not required to reload the page with the RichEdit or Spreadsheet control in the browser - end-users can continue to work with an open spreadsheet document. Each subsequent request will raise the Application_Start handler and define hibernation settings.

Example

The following code example demonstrates how hibernation settings can be defined in the Application_Start method. Some of the settings are optional.

<%@ Application Language="C#" %>
<%@ Import Namespace="DevExpress.Web.Office" %>
<script runat="server">
    void Application_Start(object sender, EventArgs e) {
        // Code that runs on application startup
        DocumentManager.HibernationStoragePath = Server.MapPath("~/App_Data/HibernationStorage/"); //Required setting
        DocumentManager.HibernateTimeout = TimeSpan.FromMinutes(30); //Optional setting
        DocumentManager.HibernatedDocumentsDisposeTimeout = TimeSpan.FromDays(1); //Optional setting
        DocumentManager.HibernateAllDocumentsOnApplicationEnd = true; //Optional setting
        DocumentManager.EnableHibernation = true; //Required setting to turn the hibernation on
    }
</script>