LocalStorage limit on PhoneGap - javascript

There is usually a limit of 5MB on localStorage on browsers, including iPhone's Safari.
Since PhoneGap has the access higher security privileges including access to other storage mechanisms on the device, in theory they should be able to eliminate the limit of 5MB.
For example, it should be able to get around the usual restrictions by storing the data on a file, etc while keeping the API compatible with localStorage javascript object.
Is this done? Or is PhoneGap limited to the same 5MB?

PhoneGap doesn't do anything out of the ordinary to extend the default limits. On Android, I get 2.5M characters in localStorage (Strings in JavaScript are UTF-16).
You can find default limits for most browsers here: http://dev-test.nemikor.com/web-storage/support-test/
This was helpful in understanding the limitations, and I used the code to create a simplified test PhoneGap app.

PhoneGap has File API that should not be affected by browser local storage limits but don't know if there exist any abstraction to make it behave as HTML5 local storage "backend".

If you want to store a large amount of data you should not do that in localStorage, there are databases and files for that kind of need. localStorage is a key-value datastore, it's use is limited and it should not be "hacked" to fit all needs.

Localstorage is something which is provided by the browser.
Localstorage is not something which is available on a device, either a mobile phone or a desktop, that is leveraged by a browser.
Since it is something which the browser provides there is no way, we can change/increase it using Phonegap since your Phonegap app runs inside the browser.
If you want more storage space, you can use a technique which Phonegap can access like a file storage or SQlLite.

Related

is there any size limit when using indexedDB in chrome browser?

i'm working on caching objects as JSON and i saw that indexedDB is a great place to do it but i'm wondering that if it has a size limit
is there any limit for indexedDB?
if it has,how can make it unlimited?
i'm using vanilla javascript
thanks a lot
As per the documentation, Chrome will reserve 1/3 of the disk for offline storage. This means if a disk is 99GB large, Chrome will reserve 33GB of storage for offline storage. I would imagine if the usable space is less than that that Chrome adjusts however much it claims to suit.
If an origin is not used often, in cases where the disk is running out of space, Chrome will delete an entire origins' offline storage. An origin can claim a maximum of 20% of the pool that Chrome has, meaning that on the aforementioned disk with 33GB of storage allocated to Chrome, you can only use 6.6GB of storage.
It's recommended though that you don't rely on having a lot of storage to play with. You should handle cases where Chrome denies you the ability to write offline storage, just like with any other app. Chrome will let you know when you attempt to write to offline storage, that you're out of storage.

Shared IndexedDB store between different web browsers

Using Dart lang, I've generated an application that stores several list of objects. I'm very happy with the result, congrats to Dart Team, but I have a question:
If I store several data using Chrome, is there any way to read this info from other web browser, i.e. Firefox.
That's why the user works with several web browsers in the same machine, he/she doesn't care which browser is open at that time, he/she wants to use the application in the current opened web browser.
Browsers can't access each other's data directly, but, given your diagram, it looks like IndexedDB is on the shared server and not in the particular browser so I can't see the problem.
If you have your database running on local server and it is accessible only with Dartium and for some reason you don't want or can't compile the browser part to JS(with dart2js) or do something else to make it accessible from the browsers without DartVM. then I can think of 3 ways how to perform browser to browser data transfer without the server(on which application is hosted):
With HTML5 Drag and Drop between browser windows.
Creating WebRTC client\server and transferring the data this way.
Using remote server and simple authentication with Gmail,Facebook etc. [the reasonable way]

Persistent local storage for both Firefox and Chrome?

Looking for advice/options for having persistent local storage using both Firefox and Chrome allowing me to save 50MB+ data. I would be storing dynamic terrain data for a WebGL game, so it wouldn't be necessary for the server to send the whole data every time the player connects. I could just update the old parts.
I thought about using an IndexedDB however Chrome doesn't allow you to increase the quota (unlike Firefox) so I wouldn't be able to store any large data. Chrome allows you to use the FileSystem API which would solve my issue however Firefox does not support it.
So it seems either way it wouldn't work. Is my only option to use the FileSystem API for Chrome and the IndexedDB for Firefox? Does anyone have any better ideas?
This info is what I've read from Mozilla's Blog and Google's Dev Site but that may be outdated now, so please feel free to correct me. Thanks!
I agree with the other comments about caching and the Chrome/Firefox marketplaces, and they may ultimately be better solutions for you. However, to answer your original question...
IndexedDB in Chrome is definitely not limited to 5 MB. You can store far more than 50 MB in IndexedDB in both Firefox and Chrome, assuming the user has enough hard drive space. Higher amounts of IndexedDB storage are regularly reached in this game I wrote. On my computer, I currently have over 500 MB stored in IndexedDB in Chrome for that one domain.
You did correctly link to https://developers.google.com/chrome/whitepapers/storage and it is quite confusing, but as I understand it, basically the upper limit is 10% of the free space on the hard drive. Another caveat described on that page is that IndexedDB is technically "temporary" storage that the browser might delete if space is running low, but in practice this seems to rarely happen (YMMV).
localStorage is limited to 5 MB (I think this was on Chrome) and you can request more space for every new 5 MB through dialog boxes.
Both localStorage and IndexedDb are created for interactive data. Because it looks like the data is not modified on the client-side your options are
Using the application cache (as mentioned in the comment)
Serving the data with cache forever HTTP headers (like 10 years), have unique URLs for new resource versions and let the browser re-download the data when it goes out of the cache (recommended)
Deploy your HTML5 application as a web app, downloads available from Chrome Store and Firefox Marketplace

storage space for mobile app using html and js

Okay, we talk and hear lot about creating mobile app using javascript and html. I was trying to write one app myself forgetting that some real programs also need to store and access at least, the information stored by the program. I intend to user only the browser of the mobile app and it is offline. Basically, it is just a program written using js. Since the browser is not allowed to create and store the data in the user's disk, how should I approach it? Storing the data in cookies is one of the option, I guess. I am new to web programming so please bear with me if I say something stupid. However, cookies can be inadvertently deleted.
So my question is: How can I manage a 'small storage space' in mobile device if I am using a html and js to create my app?
Web storage is supported by almost all modern browsers
http://caniuse.com/#feat=namevalue-storage
If you are looking for offline web applications, it is not supported from old Internet Explorer
http://caniuse.com/#feat=offline-apps
Here are a couple of useful links:
http://diveintohtml5.info/storage.html
http://diveintohtml5.info/offline.html
I believe all modern phones support LocalStorage.
In HTML5, there are a couple of ways to save information the way you want.
LocalStorage and WebDatabase
Although, if you want to do an App for iOS I recoment Web Apps, that allow you to create offline HTML application that the user see as a normal app.

Client side local storage of data

I want to store some data client side. Cookies are my first inclination, but they get sent with every request, right? Is there a way to store data without it being transferred? I don't necessarily want to add 10-20k of overhead for every request. Is the only alternative HTML 5 webstorage and how many browsers have adopted that?
html5 storage is widely deployed
HTML5 STORAGE SUPPORT
IE FIREFOX SAFARI CHROME OPERA IPHONE ANDROID
8.0+ 3.5+ 4.0+ 4.0+ 10.5+ 2.0+ 2.0+
you can find out more # http://diveintohtml5.ep.io/storage.html
No, not all cookies get sent with every request. You can check to see if a cookie exists, if not create it, and if so, read it. Cookies are still a good cross-browser option for small amounts of data.
http://fsojs.com supports robust file storage client-side, but only works with Chrome at the moment
As you have mentioned, cookies are an options and so is web storage in the HTML5 spec. There's also the ability to use Flash to store data with the added benefit that this data persists across multiple browsers on the same machine, but the drawback that you'll need a fallback for users who don't have Flash.
Personally, keeping the data on the server (identified by the session id or cookie) would be my way to do it, you have control of the data and don't have to worry about losing it when the user clears their cache or switches machines/devices. It's also the most fault-tolerant because it doesn't rely on browser features and/or plugins (other than perhaps cookies).
One more thing, if you're looking for an abstraction of client-side data storage that uses all of the above (cookies, flash, web storage) check out Evercookie

Categories

Resources