+ Reply Thread
#1
In the old developer's world, the main way of storing information in the browser is cookies.

Well, now in this ERA of HTML5, there are more than one ways of doing that.

For me, the last time I was really stranded, I built a mobile app running HTML in browser and needed browser storage, I did a quick search and came up with https://github.com/marcuswestin/store.js/

It was able to solve the problem flawlessly, it has support for old browser, and was able to solve my problem excellently. If you have issues with this type of problem or have used some libraries that actually worked, well, here is the place to share it.
#2
Storing data on the client side have been made easy by new HTML5 storage apis like localStorage, indexDB, webSQL and application cache. Although it depends on the targeted users and browser, some browers msotly old lack these features and can not really be implemented in Nigeria (where most users are with opera-mini browser). These apis can be combined to make an offline first app without the use of service workers.

When a user requests a page, appcache stores the html(including JS, css and iages) generated and can be requested on demand even without network. But talking of the data used to render the page, as we are speaking JS here I believe that the data is retrieved by JS too. So on page load with network, data is stored in the localStotrage as a JSON stringified object. Then whenever the page loads, localStorage is checked for the required data. if we have it there, load it else, retrieve from network.

Some cases will be what about the initial load of the app without application data and also no network, I have learned to always have a JS file storing it it an array of objects of the initial data for the app. This removes the headache when there is no network while the user it trying to use the app in the first place.

What if the user clears the localStorage and application cache, we reset these on the next page load to our initial data from the coupled JS file containing our single array of objects.

IndexDB and webSQL are just a bit advaced and more complex than localStorage. They provide an interface for a more eloquent and efficent way of stroing data which every SQL users will understand.

As I have said, it depends on the targeted users and browser.

When I am free I will make post on making our first offline app without the need of service workers. Purely application cache and local storage, then we can look at implementing same app with service workers. Then we compare and contrast on the pros and cons on both
Back to top