Answer the question
In order to leave comments, you need to log in
Is it possible to store large arrays in localstorage?
I'm considering a scenario for sending and receiving messages over XMPP.
Let's start with the recipient. The user opens the site, logs in, and immediately after that receives an array of the last 100 historical + n unread messages from MySql to localstorage, from where data is taken to alert and fill the page with "dialogs".
If the recipient sends a message that is transmitted via XMPP, it is written to the database with the "not read" tags, after which, if the recipient has a tab open, the message is added to the localstorage array, from the contents of which, as I said, a page with dialogs is built and it is notified, otherwise the user will download new messages from the database upon login. Those. this way I bypass loading new messages from the database.
I have questions about this:
Answer the question
In order to leave comments, you need to log in
1) You can store such data, but no one guarantees the amount of storage, as well as the safety of the content.
2) Safe from whom? Any browser user on the local computer will have access to the messages.
3) For tab logging, organize a list of unique tab keys, set the lifetime of these variables, and update them once in a short period.
In general, about all this, I think that it is not worth storing direct confidential data in unencrypted form in local storage. Use the server version, and store hashes or guid keys on the client. If the server version is not suitable in any way, use encryption using javascript methods and carefully monitor the key so that it does not exist in the browser's memory longer than the user's session.
I recommend using the jStorage library .
I draw your attention to the fact that not all browsers support the functionality properly. Have backcompatibility.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question