HTML5 Storage Wars - localStorage vs. IndexedDB vs. Web SQL
来源:互联网 发布:js重量级框架 编辑:程序博客网 时间:2024/06/05 09:41
http://csimms.botonomy.com/2011/05/html5-storage-wars-localstorage-vs-indexeddb-vs-web-sql.html
Currently, there are three competing approaches for saving serious amounts of data (i.e., persistently, and bigger than cookies) locally in your browser:
- Web Storage
- Indexed Database API
- Web SQL Database
These names sure seem similar. But the implementations sure are different. Let's quickly summarize what they do, the PROs and CONs, and what I like best at the moment. Though I'm sure my opinions will age quickly as the technology matures.
All these technologies use the same-origin protection for data access (i.e., javascript can only access data from the url's domain that it was served from), which is fine and not a differentiator so I won't mention that below.
Web Storage
Web Storage, and specifically the localStorage part of it, is a really simple key/value persistence system.
PRO: Really simple API.
PRO: Already available in all major new browsers.
CON: No query language, schemas, really nothing you'd normally call a database. So it wouldn't scale well where you need to impose organization on a larger data set.
CON: They didn't put transactional safety into the standard. I don't think I can sleep at night with an app running that might have race conditions and then have the risk of corrupt data.
Indexed Database API
IndexedDB is basically a simple flat-file database with hierarchical key/value persistence and basic indexing.
PRO: If you're a NoSQL type of person, then this might fit the bill perfectly.
CON: Not yet available in most new browsers.
CON: If you wanted SQL, you're not getting it here. Though in the future, it might be a great building block for implementing a SQL engine for the browser.
Web SQL Database
Web Sql is basically sqlite embedded into the browser. I've used sqlite off-and-on for a few years. At first I was turned off by the name (excuse my superficiality) and by the architecture (just a flat file database). But after digging into it, I found that it's a rock solid platform, and great for production use, as long as you keep in mind its limitations. Itslimitations aren't so much size (I think you can go at least 1 GB without a problem), but inherent in flat file databases (high levels of concurrency) and missing features (stored procs and other higher-end database features).
PRO: Fast and pretty feature-rich sql implementation (besides select/insert/update/delete, you can do joins, inner selects, etc).
CON: Available in Chrome and webkit-based browsers (Safari, etc.) but not Firefox or IE.
CON: The darn W3C Working Group has put a hold on the standard since they say they want at least two independent implementations of the standard, and there's only one so far, since everybody is using sqlite.
I wish the standards group would make a special case for sqlite and approve this standard -- it's in the public domain, so it's available to everybody in the world, no strings attached. Sqlite is a perfect fit for browsers - its limitations are not problems. Only one user is using a browser at a time, so no concurrency issues. And no one wants high-end database features in a simple no-administration database. I think that's why both Android and iOS use sqlite for storage.
Bottom line
If you're only deploying on mobile platforms, then Web SQL is a no-brainer. Or if you're running on desktops and can require Chrome or Safari as your browser, then Web SQL is also for you. I wouldn't use the other two standards in any heavy-duty app at the moment.
- [转载]HTML5 Storage Wars - localStorage vs. IndexedDB vs. Web SQL
- HTML5 Storage Wars - localStorage vs. IndexedDB vs. Web SQL
- Web Storage, Web SQL Database 和 IndexedDB
- IndexedDb、Web Sql、localStorage以及localForage使用
- HTML5几种存储方式 localstorage sessionstorage application cache Web SQL IndexedDB
- cookie VS web storage
- html5中的Web Storage:sessionStorage和localStorage
- 【html5】Web Storage本地存储 sessionStorage/localStorage
- html5中的Web Storage(sessionStorage、localStorage)
- HTML5 web SQL 和indexedDB的使用
- HTML5中的Web Storage(sessionStorage||localStorage)理解与简单实例
- html5中的Web Storage特性:sessionStorage和localStorage
- 浅析HTMl5中的Web Storage:sessionStorage和localStorage
- html5 web IndexedDB使用详解
- Web Storage:sessionStorage与localStorage
- Web Storage:sessionStorage与localStorage
- Web Storage 本地存储localStorage
- MyISAM VS InnoDB Storage
- Python正则表达式指南
- mba考试,有些小技巧
- AsyncTask 的用法
- Java字符串问题Top10
- linux常用指令
- HTML5 Storage Wars - localStorage vs. IndexedDB vs. Web SQL
- WebLogic:访问管理控制台
- Java获取文件类型Mime Type的各种方法
- sql基础查询(一)
- iOS7 UI改变总结
- CMUSphinx Learn - Training Acoustic Model For CMUSphinx
- OpenStack neutron floatingips 与 iptables 深入分析
- [转载] iOS开发分辨率那点事
- c3p0详细配置