Skip to content

Instantly share code, notes, and snippets.

@janl
Last active August 29, 2015 14:19
Show Gist options
  • 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:

@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