A dojo.storage IE-native module
Posted by Shane O'Sullivan on March 6, 2007
The Dojo Ajax toolkit contains a module called dojo.storage which can be used to store large amounts of non-cookie-based data on the client side. This can be useful for all manner of reasons, which you can read in Brad Neuberg’s announcement on his blog.
dojo.storage uses a very high-level API that hides the details of how exactly the storage is implemented. This is necessary because each browser forces an application to store it’s data in completely different ways. Because of this, the primary storage mechanism used in dojo.storage is Adobe Flash. Flash allows you to store up to 100K of data per page (more that 100K if you allow it), however, while Flash has a very impressive install base of over 95% of all browsers, this unfortunately is not 100%.
Because of this lack of full coverage, the WhatWG storage provider was written, which provides native storage support in Firefox 2 without Flash.
This leaves poor feeble Internet Explorer out in the cold however. So, to fix this, I’ve written a dojo.storage module that supports client side data storage in Internet Explorer. It is based on native capabilities in IE 5+ described here. I’ve submitted it as a patch to Dojo, and hopefully it’ll make it into the build over the next couple of weeks.
For those who can’t wait (and are wise in the ways of Subversion), you can download the patch from http://www.skynet.ie/~sos/misc/BrowserStorage_0.4.2.patch which you can apply to the nightly code. It was created against the 0.4.2 build. Note that this is probably not the exact code that should make it into the build, as the review process may change it slightly. However, I have tested this with IE6 and IE7, and it seems to work pretty much flawlessly.
Update: It seems that the patch was submitted too late for the 0.4.2 release, so for people who’d like to use the IEStorageProvider with the 0.4.2 release, you can apply the patch above, or download the dojo/src/storage.js and /dojo/src/storage/browser.js files. Make sure to put them in the /src and /src/storage folders respectively.
All comments/feedback/bug reports welcome, just add a comment to this post.