Improve Dashboard component's performance

Caching the backend responses

While using the SDK.UI (Dashboard component, etc.), it’s recommended to wrap the backend instance with the withCaching decorator for better performance. The decorator needs settings object to be handed over as a parameter to configure where the cache should be applied and to what size should the cache grow. For execution results, you can use either count-based eviction (maxExecutions) or time-based eviction (maxExecutionsAge). When maxExecutions is specified, it takes precedence and uses LRU policy to evict items when the limit is reached. When only maxExecutionsAge is specified, items expire after the configured duration. For other cache types, items are removed using LRU policy once the max size of the cache is reached.

You can find the recommended caching options in RecommendedCachingConfiguration within the @gooddata/sdk-backend-base package.

Caching backend configuration options

Caching optionDescriptionRecommended setting
maxExecutionsMaximum number of executions which will have their results cached (count-based eviction using LRU policy). When specified, takes precedence over maxExecutionsAge.10
maxExecutionsAgeMaximum age of cached execution results in milliseconds (time-based eviction). Only used when maxExecutions is not specified.180 000 (3 minutes)
maxResultWindowsMaximum number of execution result’s pages to cache PER result.5
maxCatalogsMaximum number of workspaces for which to cache the catalogs.1
maxCatalogOptionsCatalog can be viewed in many different ways - determined by the options specified during load.50
maxSecuritySettingsOrgsMaximum number of organizations that will have their security settings cached.3
maxSecuritySettingsOrgUrlsMaximum number of URLs per organization that will have their validation result cached.100
maxSecuritySettingsOrgUrlsAgeMaximum age of cached organization’s URL validation results. The value is in milliseconds.300 000
maxAttributeWorkspacesMaximum number of workspaces for which to cache the selected workspace attribute service calls.1
maxAttributeDisplayFormsPerWorkspaceMaximum number of attribute display forms to cache per workspace.100
maxAttributesPerWorkspaceMaximum number of attributes to cache per workspace.100
maxAttributeElementResultsPerWorkspaceMaximum number of attributes element results to cache per workspace. Note that not all the queries are cached (e.g. queries with filter value).100
maxWorkspaceSettingsMaximum number of settings for a workspace and for a user to cache per workspace.1

Example on how to use the caching backend

import {IAnalyticalBackend} from "@gooddata/sdk-backend-spi";
import {withCaching, RecommendedCachingConfiguration} from "@gooddata/sdk-backend-base";

const realBackendImplementation = ...;
const enhancedBackend: IAnalyticalBackend = withCaching(realBackendImplementation, RecommendedCachingConfiguration);