As I was looking to add an offline mode to an application, I dumped into localForage, which seems to be an interesting way to do so.
Still, I didn't get the difference it has with a simple localStorage API. Can anyone help me with that ?
If you want to store structured data on the client side, IndexedDB is the better choice, especially since localStorage isn't built to store sensitive information. But if you're storing a simple, small amount of key-value pair data, use localStorage.
Local storage is inherently no more secure than using cookies. When that's understood, the object can be used to store data that's insignificant from a security standpoint.
localForage is a JavaScript library that improves the offline experience of your web app by using an asynchronous data store with a simple, localStorage -like API. It allows developers to store many types of data instead of just strings.
The following are limitations, and also ways to NOT use localStorage : Do not store sensitive user information in localStorage. It is not a substitute for a server based database as information is only stored on the browser. localStorage is limited to 5MB across all major browsers.
LocalStorage API is synchronous and accepts simple key value strings.
LocalForage leverage this simple interface with Promises to get/set values and gives the ability to store more than converted strings as data.
If you are familiar with the logic of LocalStorage and you are experimenting with something new I suggest you give it a try.
Reference: http://blog.teamtreehouse.com/using-localforage-offline-data-storage
The benefits of LocalForage appear to be that it uses IndexedDB (with fallback to WebSQL or LocalStorage) as the storage backend. This allows it to be faster as well as not blocking execution of other code on long operations as it's API uses asynchronous promises. It also supports storing more than just strings unlike LocalStorage.
This is a good overview of LocalForage: https://hacks.mozilla.org/2014/02/localforage-offline-storage-improved/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With