Newer Version Available

This content describes an older version of this product. View Latest

Initializing Storage Service

Initialize storage in your app’s template for caching server-side action response values.

Storable actions are the only currently supported type of storage. Storable actions cache server action response values. The storage name must be actions.

Storage Entry Expiration

When you initialize storage, you can configure the expiration time, which is the duration in seconds that an entry is retained in storage.

To set the expiration time in markup, use the defaultExpiration attribute in <auraStorage:init>.

Storage Entry Refresh Interval

When you initialize storage, you can configure the refresh interval, which is the duration in seconds before an entry is refreshed in storage.

If an action matches a storage entry, the callback in the client-side controller is invoked for the cached action response.

If the response has been cached for longer than the refresh interval, the storage entry is refreshed. If the refreshed response is different from the cached response, the callback in the client-side controller is executed for a second time.

To set the refresh interval in markup, use the defaultAutoRefreshInterval attribute in <auraStorage:init>.

Initialize in Markup

This example uses a template to initialize storage for server-side action response values. The template contains an <auraStorage:init> tag that specifies storage initialization properties.

1<aura:component isTemplate="true" extends="aura:template">
2    <aura:set attribute="auraPreInitBlock">
3        <auraStorage:init
4          name="actions"
5          persistent="false"
6          secure="true"
7          maxSize="1024"
8          defaultExpiration="900"
9          defaultAutoRefreshInterval="30" />
10    </aura:set>
11</aura:component>
name
The storage name must be actions. Storable actions are the only currently supported type of storage.
persistent
Set to true to preserve cached data between user sessions in the browser.
secure
Set to true to encrypt cached data.
maxsize
The maximum size in KB of the storage.
defaultExpiration
The duration in seconds that an entry is retained in storage.
defaultAutoRefreshInterval
The duration in seconds before an entry is refreshed in storage.

For more information, see the Reference Doc App.