TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Moving beyond localStorage

208 pointsby mobitarover 8 years ago

20 comments

andrewstuart2over 8 years ago
&gt; It’s hard to believe that as of 2016, the best method for offline storage in a web app was localStorage<p>IndexedDB has been around and usable for long enough that I used it on projects &gt;3 years ago, with a fallback to localStorage just in case (looking at you, IE9). Apache Cordova even gave a nice little abstraction over sqlite so that using IndexedDB + phonegap was seamless and gave even more storage (IIRC). It was a pretty solid success for the data-heavy project I was on at the time. Load times the second time around were slashed to almost nothing. The app logic just needed to retrieve anything new since &lt;latest timestamp&gt; from the back end and update the UI.<p>Our experience was pretty great, though. I definitely highly recommend implementing some sort of domain-specific data caching layer with IndexedDB if you have the chance and if you&#x27;re moving enough data to justify it. Just make sure you think through the update logic (e.g. use timestamps or log-structured data), and handle merge conflicts appropriately if necessary (i.e. if your app can be used offline).<p>There are plenty of great wrappers out there that simplify most use cases, too. We ended up going with localForage [1] to simplify refactoring away from localStorage.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;localForage&#x2F;localForage" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;localForage&#x2F;localForage</a>
评论 #13422606 未加载
jameskiltonover 8 years ago
Maybe it is a poor example, but I don&#x27;t understand how IndexedDB and WebCrypto have anything to do with a distributed chat system like Slack.<p>For a system where I can join a channel at any time and see what&#x27;s been said in the past, the information has to live on their servers and be readable. Even more so if you want to be able to search for something someone said across your entire Slack account. You aren&#x27;t going to have all of that data local to your machine and browser.
评论 #13421409 未加载
评论 #13420450 未加载
tobltobsover 8 years ago
For everybody starting to use indexedDB I recommend to take a look at Dexie.js (<a href="http:&#x2F;&#x2F;dexie.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;dexie.org&#x2F;</a>) for a minimalistic wrapper which might save you from a lot of pain as working directly with indexedDB is no fun imho.
评论 #13421187 未加载
评论 #13423142 未加载
评论 #13428729 未加载
评论 #13421188 未加载
beardogover 8 years ago
Even worse, the pathetic 5mb limit is trivially bypassed, so it&#x27;s really just an annoying but ineffective restriction:<p><a href="http:&#x2F;&#x2F;feross.org&#x2F;fill-disk&#x2F;" rel="nofollow">http:&#x2F;&#x2F;feross.org&#x2F;fill-disk&#x2F;</a>
ummjacksonover 8 years ago
This still doesn&#x27;t explain how large scale search indexing could take place effectively... the data still needs to float upstream un-encrypted, processed and indexed.<p>Somehow offloading full-text indexing to the client, uploading encrypted indexes to the server and then elegantly combining those indexes across users to display a unified search would be arduous and I don&#x27;t see anyone doing it.<p>Also, IndexedDB has been around for <i>years</i> and still suffers from a variety of cross-browser inconsistencies that make it a little painful to work with.
AaronFrielover 8 years ago
How on earth is SlackHQ&#x27;s response reasonable? Let me count the ways it&#x27;s not.<p>There are plenty of database systems (MySQL enterprise, Postgres, Oracle, SQL Server) that support encrypted data-at-rest and there are even more ways to run a DBMS on top of encrypted disks and volumes (dm-crypt, Bitlocker).<p>Running in the cloud? Amazon AWS provides EBS encryption (and likely more) and Microsoft Azure provides data at rest encryption for all storage types (tables, queues, page and block (disk) blobs) and transparent encryption for Azure SQL Database.<p>Want more control over the encryption in the cloud? Amazon and Azure both provide HSMs, called CloudHSM and Azure Key Vault, respectively. Azure supports additional encryption at the VM level integrating with Bitlocker and&#x2F;or DM-Crypt.<p>There&#x27;s really no excuse for not having figured out data encryption for customer data and secrets at this point.<p>Edit: It appears Slack has since updated their security docs and they now use encryption at rest. Good! It&#x27;s inexplicable to me that anyone would believe that a database index would be incompatible with encryption.
评论 #13421502 未加载
javajoshover 8 years ago
Haven&#x27;t read through the WebCrypto standard, but it&#x27;s hard to create a real barrier between a server process and a client process on the web. In essence, any good crypto UI would have to happen outside of the client process, so that the server cannot intercept your input. (This is my objection to well-meaning companies that say &quot;Hey, we can&#x27;t even read your stuff, it&#x27;s encrypted on the client&quot; because, if you have auto-update, or if you ccan inject code into the client, that privacy guarantee can be revoked at any time.)
评论 #13420611 未加载
IgorPartolaover 8 years ago
Having a local storage of this type is half the problem. The other half is syncing the data between different browsers and keeping it backed up. Imagine if all your mail, years and years of it, lived in IndexDB inside your browser on your one device.<p>I think browsers should implement a standard way to sync local storage, identity information (think private keys instead of passwords), cookies, etc. across all the browsers you use. Oh and obviously it should all be encrypted at rest and you get to choose which service you use to sync the data, so you can avoid the less trusted ones. What kind of utopia would this be?
red_admiralover 8 years ago
The sad thing is, there was this idea for WebSQL ages ago and it would have solved this problem AND made database-backed apps easy to write, plus firefox and chrome already use sqlite internally so you could reuse that as the engine. Apparently it wasn&#x27;t hip enough for the NoSQL folks though.
评论 #13421317 未加载
n0usover 8 years ago
Assuming you are storing only encrypted data on the server and cannot read it without the user&#x27;s password, what happens if the user loses their password? Are they just left with a bunch of unreadable data that came from the server?<p>Doesn&#x27;t this approach also make it difficult to share information between other users?<p>Having offline-first, client side encrypted apps seem to have a lot more problems than just &quot;you know who&quot; spying on you.
评论 #13420739 未加载
vmorgulisover 8 years ago
More details about the 50% disk space limit: <a href="https:&#x2F;&#x2F;www.raymondcamden.com&#x2F;2015&#x2F;04&#x2F;17&#x2F;indexeddb-and-limits" rel="nofollow">https:&#x2F;&#x2F;www.raymondcamden.com&#x2F;2015&#x2F;04&#x2F;17&#x2F;indexeddb-and-limit...</a>
skybrianover 8 years ago
re: &quot;But if the server could read your data, then practically any engineer of the company could read your data [...]&quot;<p>A caveat: this tends to be true of startups. If you don&#x27;t know who you&#x27;re dealing with, it&#x27;s probably a safe assumption to make. But larger companies often have internal permissions in place to prevent any engineer from reading user data.
dumbmatterover 8 years ago
First time I&#x27;ve ever seen the IndexedDB API described as &quot;delightful&quot;.
fatamorganaover 8 years ago
Hey, I&#x27;m kind of a novice to web dev (especially when it comes to security) so could somebody please explain why you can&#x27;t implement end-to-end encryption and search capability ?
评论 #13425297 未加载
johne20over 8 years ago
How do others handle cross subdomain support of local data? IndexedDB and localStorage do not support subdomains best I can tell.<p>eg. mysite.com and app.mysite.com sharing local db.
评论 #13422481 未加载
srikuover 8 years ago
A question - does it matter for webcrypto API&#x27;s trustability to have window.crypto be redefinable to anything a piece of JavaScript code desires? (Ex: extensions)<p>I find it hard to make any claims about safe local encryption using webcrypto API if, post encryption, a new extension can be installed that will sniff the keys as you decrypt to access your data.<p>Thoughts?
评论 #13426746 未加载
flukusover 8 years ago
The solution is easy, make a real app.
kodfodraszover 8 years ago
This article is a very long write about nothing. Throws up topics and questions, and provides no explaination or answer.<p>An example of medium click bait that leads to medium&#x27;s eventual demise. Being a platform for badly written PR bullshit will not work out for medium imho.
draw_downover 8 years ago
So after a bunch of work is done, I can have search on Slack like I have now. I understand it&#x27;s better to have my chats encrypted at rest, but I wonder how many users are interested enough in that to make this change happen.
评论 #13421121 未加载
Sir_Cmpwnover 8 years ago
WebCrypto is security theater. The server could just swap the JS for a version that decrypts your secrets client-side and uploads the plaintext (or just uploads the key) to the server. Next time you hit the page your secrets are compromised.<p>Also, if you use &quot;50% of the user’s disk space&quot; you can go fuck yourself.
评论 #13425130 未加载