How to store data locally?

别等时光非礼了梦想. 提交于 2019-12-08 02:52:51

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!