Skip to content

Instantly share code, notes, and snippets.

@janl
Last active August 29, 2015 14:19
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janl/d8efa4e404072037f7e0 to your computer and use it in GitHub Desktop.
Save janl/d8efa4e404072037f7e0 to your computer and use it in GitHub Desktop.

@ppk asks: “OK, suggestions for my next bit of research?” — https://twitter.com/ppk/status/587545743625478144

@rem replies: “@ppk storage. What works in browser, what browsers, what phones, how it changes when *added to home screen", limits, etc. How's that?” — https://twitter.com/rem/status/587566978065367040

Here’s what I whipped up, please add more in the comments:

APIs:

Topics:

  • compability across a broad browser matrix (hello Mobile Safari)
  • storage limits across browsers and OSs
  • eviction policies per browser/OS
  • storing objects vs. storing text vs. storing binary data / Blobs

See also:

@jakearchibald
Copy link

@pp-koch
Copy link

pp-koch commented Apr 13, 2015

Looking for

  • simplified overview of WebSQL (basically a list of methods and properties with summaries of their use)
  • info on FileAPI (again, list of methods and properties); got intro on http://www.html5rocks.com/en/tutorials/file/filesystem/ , but a good list would be even better
  • NO tools please; I only test browsers

@janl
Copy link
Author

janl commented Apr 13, 2015

Existing research into browser storage quotas: http://www.html5rocks.com/en/tutorials/offline/quota-research/

@janl
Copy link
Author

janl commented Apr 13, 2015

@ppk: listed PouchDB because they have tons of stuff on underlying storage mechanisms.

@nolanlawson
Copy link

IndexedDB/WebSQL browser quirks:

Cool stuff you can do with IndexedDB (Dexie is awesome btw):

IndexedDB 2.0 proposal:

Obscure storage methods:

One bit of research that hasn't been explored yet AFAIK: it seems "officially" both WebSQL and IndexedDB are ephemeral (see this and this), but in practice I've only heard of iOS randomly deleting data. And even then, it's just hearsay. It would be interesting to know which browsers wipe data, what the threshold is, etc.

@pp-koch
Copy link

pp-koch commented Apr 13, 2015

@janl: Yes, I get that, but others might want me to test tools or go through a script they wrote. I won't.

@janl
Copy link
Author

janl commented Apr 13, 2015

@ppk cool!

@nolanlawson
Copy link

@pp-koch: the surprising truth about WebSQL is that it really is just SQLite. I've found the question isn't "which SQLite methods can you use?" but rather "which ones can't you use?".

E.g. we use sqlite_master in PouchDB itself, and full-text search is also supported (demo). I know pragma is unsupported, not sure about more exotic ones like vacuum.

@nolanlawson
Copy link

Also the issue of binary data in the browser (blobs, arraybuffers, etc.) is probably worthy of its own blog post, but there's some info here:

  • http://pouchdb.com/faq.html#data_types (Chrome has had four major Blob bugs which they finally fixed as of v43, IE and Firefox has been good pretty much since day 1, Safari doesn't support it in IndexedDB among other stuff they don't support, binary data in WebSQL is super weird)
  • https://github.com/nolanlawson/blob-util (some mention of which APIs aren't supported by which browsers, with Android/Firefox/IE being the big offenders, but really you'd have to see the source code to know exactly which ones, mostly BlobBuilder/canvas/FileReader stuff)

Also sorry I'm focusing mostly on the negative, but figured it's best to take a hard look at browser storage in all its gory detail. 😃

@pp-koch
Copy link

pp-koch commented Apr 13, 2015

@nolanlawson: Fine, but I know nothing about SQL, so WebSQL being SQLite doesn't really help me.

In fact, this may be a serious problem for my research. But I'll start with localStorage, I decided that much, particularly since I have some old tests lying around somewhere.

@PaulKinlan
Copy link

In save to homescreen mode (Chrome) there will be no difference today. Other browsers though, would be interesting to know

@jakearchibald
Copy link

I know that iOS Safari drops indexeddb support when launched from homescreen

@pp-koch
Copy link

pp-koch commented Apr 13, 2015

Is launched from homescreen a different use case than using the WebView?

@nolanlawson
Copy link

@pp-koch: UIWebView, WKWebView, homescreen app, iOS Safari, and even Chrome on Safari (!): none of the above should be considered equivalent. I've seen WebSQL/IndexedDB issues that occur in only one of the above. The Raymond Camden article has them all listed in the comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment