save to localstorage before send to server periodically