December 27, 2009

client side storage: persistjs

Current project that i'm working on, works like a plugin to an existing website. To match to the scale we are targeting, we decided to go the stateless way on the server side; so that we don't necessarily need a sticky behavior on the server side. Now this raised requirement to store state and related data on the client side. On each request client sends the "exactly required" state to the server and server decides on things that need to be done.

If you've read my previous post on cookie size limitations in browsers; you would understand this cannot be done at all. To add to the problem, this project being a web plugin to an existing site, needs to share the cookie space with them and their already existing plugins. We were really concerned if we end up messing with their cookies or they end up messing up with ours (given the size limitation).

And then we found persistjs. You should read all the good reasons why you should use persistjs here. In short, it tries to find multiple possible way to store and retrieve data on the client side. If one method fails, it fall backs to the next available method. The last being cookies and before that flash. This was a relief to us because web stats show ~99% browsers support flash and ~70-80% already have flash plugin installed. In all good/bad probablities, we will end up with a browser which supports one of the client side storage supported by persistjs. It currently supports the following:
  • flash: Flash 8 persistent storage.
  • gears: Google Gears-based persistent storage.
  • localstorage: HTML5 draft storage.
  • whatwg_db: HTML5 draft database storage.
  • globalstorage: HTML5 draft storage (old spec).
  • ie: Internet Explorer userdata behaviors.
  • cookie: Cookie-based persistent storage.

Not only that, if we land up to a backend other than the cookie; minimum supported size is ~100KB. Good enough for us. :-)

Thats it for now. We seem to be in good shape on this side. Soon we will be going for full throttle load testing. Will share the results then. Till then, merry christmas (belated) and happy new year (in advance). [;-)]

No comments: