I am building web analytics tools which deal with tracking the click events and mouse movements
, For this, I don't want to send the data to the server for every mouse move
or click
, instead I planned to save locally and send the data to the server at session time out or while closing the browser or tab (closing the web site).
Note: Large amount of data is to be stored locally.
I know some possible ways to store the data locally.
1.LocalStorage:
Drawbacks: Domain Specific so i can't rely on this.
2.Cookie
Drawbacks: 1.Analytics fails if cookie is disabled
2.Not possible to store large amount of data
(scenario: Every mouse movement
co-ordinates should be captured)
I have two questions:
1.Whether storing data locally is good practice (specifically with web analytics)?
2.Is there any other possible ways of storing large amount
(cannot assume) of data locally?
At least Safari and Chrome have a Web SQL Database API so you'll be able to use sqlite instead of raw local storage. I found a good article about sqlite usage in web browser.
An other option would be to keep your data straight in memory (and push it to the server when a certain size is reached).
来源:https://stackoverflow.com/questions/15876098/how-to-store-data-locally