Skip to main content
All docs
V24.1

Hibernate a Document

The DocumentManager can release server memory from inactive open documents and save them to a server’s file system. This behavior reduces server memory consumption and prevents the loss of unsaved changes should the web server restart. When a user interacts with a hibernated document, the DocumentManager restores the document from the file system to the server’s RAM.

Note

The Spreadsheet loses undo/redo history after hibernation.

To enable hibernation, call the AddHibernation method and assign a server directory path to the StoragePath property. You can configure the following optional hibernation settings:

Timeout
Specifies the idle timeout period upon which the DocumentManager hibernates an open document. The default value is an hour.
DocumentsDisposeTimeout
Specifies how long to store hibernated documents in the server directory prior to disposal. The default value is a day.
AllDocumentsOnApplicationEnd
Specifies whether to hibernate all open documents at the application level.

The example below demonstrates how to configure hibernation settings as requirements dictate:

builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.AddDevExpressControls(options => {
    options.AddSpreadsheet(
        spreadsheetOptions => {
            spreadsheetOptions
                .AddHibernation( hibernationOptions => {
                    hibernationOptions.StoragePath = Path.Combine(builder.Environment.ContentRootPath, "HibernationStorage");
                    hibernationOptions.Timeout = TimeSpan.FromMinutes(20);
                    hibernationOptions.DocumentsDisposeTimeout = TimeSpan.FromDays(2);
                    hibernationOptions.AllDocumentsOnApplicationEnd = true;
                });
        }
    );
});