{"id":1621,"date":"2009-04-21T12:26:18","date_gmt":"2009-04-21T20:26:18","guid":{"rendered":"http:\/\/mozillalabs.com\/?p=1621"},"modified":"2009-04-21T12:26:18","modified_gmt":"2009-04-21T20:26:18","slug":"towards-better-browser-storage","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/labs\/2009\/04\/towards-better-browser-storage\/","title":{"rendered":"Towards Better Browser Storage"},"content":{"rendered":"<p>As Web applications become more powerful and useful, the need has arisen for them to be able to store structured information in the user&#8217;s browser. This is the problem that the W3C&#8217;s <a href=\"http:\/\/dev.w3.org\/html5\/webstorage\/\">Web Storage specification<\/a> has set out to solve.<\/p>\n<p>At the moment, the specification aims to expose a particular implementation of SQL to web pages.  <a href=\"http:\/\/blog.vlad1.com\/\">Vladimir Vuki\u0107evi\u0107<\/a> has written about <a href=\"http:\/\/blog.vlad1.com\/2009\/04\/06\/html5-web-storage-and-sql\/\">flaws in this approach<\/a>.  Among them are:<\/p>\n<ul>\n<li>While a lot of server-side developers already know SQL, it&#8217;s actually quite low-level and not very easy to use. This goes against the grain of the Web as a platform, which is something that should be as easy to develop for as possible.<\/li>\n<li>There&#8217;s no useful core SQL standard, and as a result the specification effectively says &#8220;do what SQLite does&#8221;. Because &#8220;what SQLite does&#8221; isn&#8217;t well-defined and can change in future versions of SQLite, it effectively means tying all browsers to a particular implementation, and any security vulnerabilities that the implementation may have.<\/li>\n<\/ul>\n<p>It seems that a different approach is required and we&#8217;re highly interested in exploring alternative proposals to SQLite for Web Storage.<\/p>\n<p>I&#8217;ve recently undertaken an <a href=\"http:\/\/www.toolness.com\/wp\/?p=580\">experimental re-implementation of CouchDB<\/a> in the browser to explore the possibilities of using a simpler standard that delegates many of its semantics to the JavaScript language and is also easily parallelizable to take advantage of multiple processor cores. For instance, putting posts into a blog database might look something like this:<\/p>\n<pre>\nblogDb.put(\n  [{author: 'Myk', title: 'Burritos',\n    content: 'Burritos are yum.'},\n   {author: 'Thunder', title: 'Bacon',\n    content: 'I like bacon.'},\n   {author: 'Thunder', title: 'Beer',\n    content: 'Beer is good too.'}],\n  function onDone() { \/* Do stuff... *\/ }\n);\n<\/pre>\n<p>Take a look at the <a href=\"http:\/\/hg.toolness.com\/browser-couch\/raw-file\/blog-post\/tutorial.html\">BrowserCouch Tutorial<\/a> for more information on how this kind of Web Storage API would look and work&mdash;it also lets you play around with the MapReduce algorithm interactively, so you can really get a feel for it.<\/p>\n<p>Please do let us know what you think, or if you have other ideas on how best to approach Web Storage.<\/p>\n<p><em>&#8212; Atul Varma, on behalf of the Mozilla Labs team<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As Web applications become more powerful and useful, the need has arisen for them to be able to store structured information in the user&#8217;s browser. This is the problem that the W3C&#8217;s Web Storage specification has set out to solve. &hellip; <a class=\"go\" href=\"https:\/\/blog.mozilla.org\/labs\/2009\/04\/towards-better-browser-storage\/\">Continue reading<\/a><\/p>\n","protected":false},"author":51,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[4863],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts\/1621"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/users\/51"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/comments?post=1621"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts\/1621\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/media?parent=1621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/categories?post=1621"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/tags?post=1621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}