我有一个使用appcaching的离线web应用程序。我需要提供它大约10MB - 20MB的数据,它将保存(客户端)主要由PNG图像文件组成。具体操作如下:
从服务器PNG数据文件中下载和安装
下面是我目前对处理二进制blob存储的基于客户端的“数据库”的分析
请参阅底部的更新
- CON: any change of a PNG database item will mean complete download of all items in manifest (Really bad news!)
- CON: Designed for JSON storage
- CON: can only store blobs via base64 encoding (probably fatal flaw due to cost of de-encoding)
- CON: Hard limit of 5MB for webStorage [http://htmlui.com/blog/2011-08-23-5-obscure-facts-about-html5-localstorage.html](http://htmlui.com/blog/2011-08-23-5-obscure-facts-about-html5-localstorage.html)
- CON: Sponsor will reject it as a native app requiring certification
- Server creates a zip file, places it in wwwroot, and notifies client
- user has to manually unzip (At least that is how I see it) and save to client file system
- Web app uses FileSystem API to reference files
- CON: ZIP might be too large (zip64?), long time to create
- CON: Not sure if FileSystem API can always read out of the sandbox (I think so)
- The user will be local to the server before going offline
- So we could have him insert a SD card, let the server fill it with PNG files
- Then the user will plug it into the laptop, tablet
- Web app will use FileSystem API to read the files
- CON: Not sure if FileSystem API can always read out of the sandbox (I think so)
- CON: w3c has abandoned it (pretty bad)
- I might consider a Javascript wrapper that uses IndexedDB and WebSQL as a fall-back
- Chrome supports read/write of blobs
- CON: not clear about IE and FireFox (IE10, has non-standard msSave)
- caniuse.com reports IOS and Android support (but again, is this just r/w of JSON, or does it include the full blob API for writing?
- CON: FireFox folks dislike FileSystem API & not clear if they are supporting saving blobs: [https://hacks.mozilla.org/2012/07/why-no-filesystem-api-in-firefox/](https://hacks.mozilla.org/2012/07/why-no-filesystem-api-in-firefox/)
- PRO: _Much_ faster than IndexedDB for blobs according to jsperf [http://jsperf.com/indexeddb-vs-localstorage/15](http://jsperf.com/indexeddb-vs-localstorage/15) (page 2)
- Good support in IE10, FireFox (save, read blobs)
- Good speed and easier management than a file system (deletes, updates)
- PRO: see speed tests: [http://jsperf.com/indexeddb-vs-localstorage/15](http://jsperf.com/indexeddb-vs-localstorage/15)
- See this article on storing and display of images in IndexedDB: [https://hacks.mozilla.org/2012/02/storing-images-and-files-in-indexeddb/](https://hacks.mozilla.org/2012/02/storing-images-and-files-in-indexeddb/)
- CON: I confirmed that Chrome does not yet support blob writing (current bug, but not clear when it will be fixed)
- UPDATE: [A June 2014 blogpost](https://developers.google.com/web/updates/2014/07/Blob-support-for-IndexedDB-landed-on-Chrome-Dev) suggests Chrome now supports blobs in `IndexedDB`
- UPDATE: [This caniuse/indexeddb](https://caniuse.com/#search=indexeddb) confirms: "Chrome 36 and below did not support Blob objects as indexedDB values."; suggesting >Chrome36 supports Blob objects.
- PRO: very clean wrapper for IndexedDB, WebSQL or whatever database you have (think polyfill)
- CON: cannot store binary blobs, only data:uri (base64 encoding) (probably fatal flaw due to cost of de-encoding)
polyFill JQUERY
- Parashuram has writtent a nice JQUERY wrapper for the raw IndexedDB interface
- PRO: greatly simplifies using IndexedDB, I was hoping to add a shim/polyfill for Chrome FileSystemAPI
- CON: It should handle blobs, but I was unable to get it to work
- Eric Bidelman @ Google has written a well tested PolyFill the FileSystem API that uses Indexed DB as a fall back
- PRO: FileSystem API is well suited for storing blobs
- PRO: works great on FireFox and Chrome
- PRO: great for synchronizing with cloud based CouchDB
- CON: no clear why, but it is not working on IE10
- great for syncing a CouchDB with a local DB (uses either WebSQL or IndexedDB (not my problem though)
- CON: NO CONS, PouchDB now supports binary blobs for all recent browsers (IE, Chrome, Firefox, Chrome on mobile, etc.) as well as many older browsers. That was not the case when I first did this post.
注意:为了查看PNG的data:uri编码,我在http://jsbin.com/ivefak/1/edit上创建了一个示例。
所需的功能(/u)
IndexedDB Implementations
SQL database
传统的键/值存储
My Current Results
最终结果发布在下面作为answer
更新
PouchDB现在支持所有最新浏览器(IE、Chrome、Firefox、移动上的Chrome等)的二进制blob。以及许多较老的浏览器。当我第一次写这篇文章时,情况并非如此。
发布于 2013-01-24 01:14:05
PNG滑动贴图的脱机blob缓存结果
测试
Chrome
从web服务器获取
存储
适用于IE和FireFox
stored separately)
显示
我将基于DB的tiles层与纯本地( storage
之间
结果
发布于 2013-01-02 05:38:13
对于您的需求,我建议基于另外两种填充方式开发一种新的填充方式:和IndexedDB to WebSQL -是最好的选择。
前者将支持在Chrome (FileSystem API)和Firefox (IndexedDB)中存储blobs,而后者应该支持Android和iOS (WebSQL)。我们需要做的就是让这些多层填充一起工作,我想这并不难。
NB:因为我在网上找不到任何关于这方面的信息,你应该测试一下使用WebSQL polyfill存储斑点是否可以在iOS和安卓上工作。不过,看起来它应该可以工作:
var sql = ["CREATE TABLE", idbModules.util.quote(storeName), "(key BLOB", createOptions.autoIncrement ? ", inc INTEGER PRIMARY KEY AUTOINCREMENT" : "PRIMARY KEY", ", value BLOB)"].join(" ")
发布于 2013-05-24 17:16:46
我有地图缓存examples(打开示例,发现区域和缩放,切换离线和发现的区域将可用)。
有用于离线磁贴的map.js
- map层,基于IndexedDb和WebSQL的storage.js
- storage实现(但这只是测试实现,性能很差)。
站点文件(html、css、js等)的
有关20亿城市(Minsk)规模的其他信息:
https://stackoverflow.com/questions/14113278
复制相似问题