Storable Actions

Enhance your component’s performance by marking actions as storable to quickly show cached data from client-side storage without waiting for a server trip. If the cached data is stale, the framework retrieves the latest data from the server. Caching is especially beneficial for users on high latency, slow, or unreliable connections such as 3G networks.
Warning

Warning

  • A storable action might result in no call to the server. Never mark as storable an action that updates or deletes data.
  • For storable actions in the cache, the framework returns the cached response immediately and also refreshes the data if it’s stale. Therefore, storable actions might have their callbacks invoked more than once: first with cached data, then with updated data from the server.

Most server requests are read-only and idempotent, which means that a request can be repeated or retried as often as necessary without causing data changes. The responses to idempotent actions can be cached and quickly reused for subsequent identical actions. For storable actions, the key for determining an identical action is a combination of:

Marking an Action as Storable

To mark a server-side action as storable, call setStorable() on the action in JavaScript code, as follows.

action.setStorable();
Note

Note

Storable actions are always implicitly marked as abortable too.

The setStorable function takes an optional argument, which is a configuration map of key-value pairs representing the storage options and values to set. You can only set the following property:

ignoreExisting
Set to true to bypass the cache. The default value is false.
This property is useful when you know that any cached data is invalid, such as after a record modification. This property should be used rarely because it explicitly defeats caching.

To set the storage options for the action response, pass this configuration map into setStorable(configObj).