Newer Version Available
Caching with Storage Service
The advantage of using the Storage Service instead of other caching infrastructures, such as Apple local storage for iOS devices, is that the Storage Service offers several types of storage through adapters. Storage can be persistent and secure. With persistent storage, cached data is preserved between user sessions in the browser. With secure storage, cached data is encrypted.
| Storage Adapter Name | Persistent | Secure |
|---|---|---|
| SmartStore | true | true |
| IndexedDB | true | false |
| MemoryAdapter | false | true |
- SmartStore
- (Persistent and secure) Provides a caching service that is only available for apps built with the Salesforce Mobile SDK. The Salesforce Mobile SDK enables developing mobile applications that integrate with Salesforce. You can use SmartStore with these mobile applications for caching data.
- IndexedDB
- (Persistent but not secure) Provides access to an API for client-side storage and search of structured data. For more information, see the Indexed Database API.
- MemoryAdapter
- (Not persistent but secure) Provides access to the JavaScript main memory space for caching data. The stored cache persists only per browser page. Browsing to a new page resets the cache.
The Storage Service selects a storage adapter on your behalf that matches the persistent and secure options you specify when initializing the service. For example, if you request a persistent and insecure storage service, the Storage Service returns the IndexedDB storage.
When you initialize storage, you can set certain options, such as the name, maximum cache size, and the default expiration time.
Server-side actions storage is the only currently supported type of storage. Storage for server-side actions caches action response values. The storage name must be actions.