What is the Best Practice? Browser extension store JSON data - arrays

I am creating a browser extension which retrieves data from a JSON feed.
I would like to store this data locally to prevent having to fetch the feed to often. The feed will eventually have over 100 results and the call is made on every new website that is visited, in the end I need an array with the results.
I am not sure at all on how to do this, but I guess (wild guess) that I have two options:
Option 1:
Store it all with chrome.storage.sync.set, will I be able to do this with such a large array?
And only refresh from feed every week.
or
Option 2:
Write my array to a local file containing the entire array.
And only refresh from feed every week.
Does anyone have any ideas on how to do this? Are both options actually possible? Which would be best?

You can use https://developer.chrome.com/extensions/storage to save your data. Usually the local storage is enough. Sync is used when you need to sync saved data across different user profile instances (when user logged in chrome with same account on desktop and notebook for example)
Also you can store data via file using filesystem api or webstorage api like IndexedDB or WebSQL - https://developer.chrome.com/apps/offline_apps.

Related

Browser cache or Local storage?

I have a huge list of products like 800-1000 may be more[dynamic].In the admin panel I want to show the list. Each time fetching the data takes time and admin has to wait. So if I want to save the data on first fetch and store it locally to reuse faster.
Which one would be better local storage or browser cache ?

I'm trying to store a large amount of data and I want it to be accessable in the app that my users download

So I have an array of a couple hundred universities and I want my users to be able to select one. I have tried storing data in firebase database and then requesting the data, but firebase is just awful with arrays, I have tried calling some api, but I didn't like how they didn't work how I wanted. So now I'm trying to do it with local storage (like Core Data), but all the implementations that I have seen right now only have the user add data. I want to store the array and I want every user to have access to it.
You can write tool to add data into model file or create core data empty store and add data manually.
After populating data grab the file and add it into your project.

Save data from firebase real time database to android local database (SQLite)

I wanted to save all my data from firebase database into a local database in (JSON format only) for my application to access it when not connected to internet. It consists even images in it along with string form of data.
Firebase allots very less space for offline mode saving data into the application hence can't use it.
I want data to be first saved in my local database and then to be retrieved into the recyclerView of my application.
Moreover I want to save login details as well as other user specific details required to keep the application function without internet into particular user's login.
Searched for answers but no reliable or step by step guide I encountered.
Are these things possible? What should I do ? Please guide.

What is the best approach to work with data while using token based authentication

I am building an sample application that lets user store comments.
I've created the registration and login process. When the user registers, his details are stored in a MySQL database and a token is returned to the browser. Now he can access the Profile page.
When an existing user logs in he is redirected to the profile page. The profile page is accessible only when a user registers or logs in.
After logging in, I want to show all his comments if he has already added them.
My frontend is in Angular and backend use Laravel. For authentication I use Satellizer.
I want to know, what is the best approach while playing with data, considering the fact that the user will add, edit his comments. Should I use localstorage and store data in a key value pair or should I create a json file which gets updated everytime the user adds a comment or makes a change.
I wanted to know what is the most efficient way to deal with data from server so that the application is fast even when it scales to a 10000 users and lot of data for each user.
Thanks
You should be updating it on the server when changes are made rather than only relying on localstorage. You can use localstorage to cache, but it should only be for immutable data, it shouldn't really be used for data that is going to change.
So in this case you'll be adding and updating new comments via your API (ideally a RESTful one!). Once you've made a change, you could store the comments locally and only update them when the user makes a new comment, however you'll quickly run into issues where the data is invalid on different clients. (i.e. if you update the comments on a different computer, the other computer won't be aware).
Alternatively, you could cache the comments and then simply ping the server to find out if new comments have been added. This could be using a HEAD request for example to check the last modified date on your comments resource.
You can store comments data locally on user browser, but you should properly manage it.
I don't how much load your server will have and if the time invested now worths it.
You can fetch comments and store them locally
User adds a comment, then you update locally and send a request to the server
You need to track the request response, if requests fail so notify user and remove comments from local.
if request was successful so you can continue on your way.
** facebook uses this "success first" approach
user does an action, and he see it happens instantly, in the background it could take few seconds, only if it fails they will notify you.
** look at their commenting process, when you comment, it appears instantly, no loading... but in the BG the load happens.

Store intermediate form data

In a web application, we often come across a form submission process that spans across several pages, for ex: In first form we capture basic information, next page capture some other information and so on. I have a scenario where I've 7 screens to capture all the details about user and "Submit" button appears on 7th page.
Usually we store all the intermediate values in HttpSession and when its time to submit we retrieve all the values from Session and create an entry in database.
With this approach, by the time user completes all the form entries (i.e. from Page 1 to Page 7), everything resides in Session.
I would like to know, is there any alternative apart from HttpSession for storing the intermediate values?
I'm actually trying to find the ways to make my HttpSession less bulky.
You can also store just the reference in a session which then maps to a cache like e.g. Memcached. Or if it is important that you don't lose the data while the user walks through the steps, you can also persist the data in a database and just refer via a key from a session to it. To store too much data in the session is sometimes not the best choice, so I would just store a reference there.
You can try caching technology of .Net, this might be useful instead of using session for all the data, also you can just use the id of the session for the cache id.
Second option I think is configuring your Session-State mode to use SQLServer mode for the storage.

Resources