Persistent storage on client side
Asked Answered
A

7

9

Is there any way to have some persistent data (like an XML file or so) apart from cookies at client side? I know that's not possible with JavaScript directly. But any other way like Applets or something??

Airline answered 25/11, 2010 at 15:10 Comment(1)
A java applet can do it if it is digitally signed. But I personally wouldn't install a signed applet from an untrusted source due to the potential security hole that it opens.Buprestid
P
5

If cookies won't suffice, and you have to support older browsers, then LawnChair might help: http://brian.io/lawnchair/plugins/

It's like a "Couch" but smaller, get it? Took me a few minutes ;).

And, it does work for desktop browsers, despite the blurb on the site about mobile-webkit: https://github.com/brianleroux/lawnchair/blob/master/README.md.

(But, it uses cookies as the adapter to store data for the fallback on those older browsers, most such libraries probably will, if you're not allowed to use cookies for some reason, these types of libraries might not fit the bill.)

Pennon answered 25/11, 2010 at 15:36 Comment(6)
But we have a limit on number of cookies to be stored right? or is that only for server side?Airline
Yes, cookies have limits (depends on the browser, but 4kb max per cookie, and sometimes as few as 30 allowed per domain), and so do the other local storage solutions, even HTML5 local storage. It depends on what you want to store, but you need to keep in mind it's the client side, you generally want to keep minimal data there. Also, all these alternatives, and a few more, are listed here: en.wikipedia.org/wiki/HTTP_cookie#Alternatives_to_cookies.Pennon
It sounds to me like LawnChair and the YUI solution Yeameen noted are similar, a nice JS API and they encapsulate the storage mechanism based on browser platform. I'd look at those (or other similar offerings).Pennon
Even the DOJO toolkit does the same thing.Airline
The first link in this answer is broken. Has the site been moved elsewhere?Derwin
@AndersonGreen I've edited the answer with the new link : brian.io/lawnchair/plugins . May not be visible till it's peer reviewedMarrissa
B
5

The latest browsers are supporting HTML5 Local Storage.

If the client doesn't support HTML 5, the Google Gears plugin allows local storage.

Buprestid answered 25/11, 2010 at 15:23 Comment(2)
Gears is great, and was used for a lot of stuff for a while, but they understandably shifted efforts to HTML5 earlier this year (gearsblog.blogspot.com/2010/02/hello-html5.html). Gears does it, by being a plugin (requires user to install, etc.).Pennon
Google Gears is now deprecated.Keslie
P
5

If cookies won't suffice, and you have to support older browsers, then LawnChair might help: http://brian.io/lawnchair/plugins/

It's like a "Couch" but smaller, get it? Took me a few minutes ;).

And, it does work for desktop browsers, despite the blurb on the site about mobile-webkit: https://github.com/brianleroux/lawnchair/blob/master/README.md.

(But, it uses cookies as the adapter to store data for the fallback on those older browsers, most such libraries probably will, if you're not allowed to use cookies for some reason, these types of libraries might not fit the bill.)

Pennon answered 25/11, 2010 at 15:36 Comment(6)
But we have a limit on number of cookies to be stored right? or is that only for server side?Airline
Yes, cookies have limits (depends on the browser, but 4kb max per cookie, and sometimes as few as 30 allowed per domain), and so do the other local storage solutions, even HTML5 local storage. It depends on what you want to store, but you need to keep in mind it's the client side, you generally want to keep minimal data there. Also, all these alternatives, and a few more, are listed here: en.wikipedia.org/wiki/HTTP_cookie#Alternatives_to_cookies.Pennon
It sounds to me like LawnChair and the YUI solution Yeameen noted are similar, a nice JS API and they encapsulate the storage mechanism based on browser platform. I'd look at those (or other similar offerings).Pennon
Even the DOJO toolkit does the same thing.Airline
The first link in this answer is broken. Has the site been moved elsewhere?Derwin
@AndersonGreen I've edited the answer with the new link : brian.io/lawnchair/plugins . May not be visible till it's peer reviewedMarrissa
N
2

We have been using YUI's local storage wrapper without any issue for quite some time. The library automatically uses best available storage option and supports almost all browsers; IE6+, Firefox2.0+, and newer Safari, Chrome and Opera.

Nydianye answered 25/11, 2010 at 15:35 Comment(0)
C
1

Html5 local storage is definitely the answer, if you want an example on how to use this feature , check if the browser supports it and how to iterate over the items check this link: http://geoffrey.vandiest.biz/post/2011/04/30/HTML5-Local-Storage.aspx

Custard answered 30/4, 2011 at 13:34 Comment(0)
Y
1

This is an old question, but there are some really nice newer HTML5 technologies for client-side storage worth looking into. you can do it in the javascript now.

The File-System API and IndexedDB are definitely worth looking into and should be around to stay!

To avoid security issues the files you store on the client machines are sandboxed and obfuscated on the client side.

File-System API

File-System API and for the browsers that don't yet support the File-System API there is a js you can include to get the desired functionality. You can request Temporary or Persistent Storage. The only limitation to your file size with the File-System API is the ammount of free space on the client's harddrive (coupled with the quota you request). Temporary storage within the file-system api will only get you several hundred MB max (a couple GB if you are lucky). I use double digit GBs with PERSISTENT storage for web applications with little to no issues.

IndexedDB

IndexedDB is a more widely browser supported technology. There are more file size limitations for indexedDB, typically you'll be able to get up to a couple hunded MB of space using Quota requests.

Yapok answered 31/1, 2014 at 16:45 Comment(0)
E
1

If you're working in Google Chrome, FSO.js wraps the asynchronous FileSystem API for you and is very easy to use.

This technology should be supported by other browsers soon.

Eatton answered 27/2, 2014 at 21:20 Comment(0)
M
0

I happened to stumble across this Wiki page that lists down a lot of persistent JS stores : https://github.com/bebraw/jswiki/wiki/Storage-libraries

Marrissa answered 21/2, 2013 at 8:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.