After I tried to use PersistJS, I am impressed. Then people are asking me to write-up my findings. So, here are my notes about PersistJS:
The first recommended reading is Why This is Awesome section. It makes a good case why you should use PersistJS. One interesting aspect of PersistJS is explained in its README: “Each backend is wrapped by PersistJS and exploses the exact same interface, which means you don’t have to know or care which backend is being used.” This means that you are not limited by a single technology and this enables you to adopt to a different storage easily. This statement might leave you with the question about which one does PersistJS choose? To answer this question, I found the order which PersistJS chooses a back-end store:
In my first implementation that uses PersistJS, I did not load
extras/swfobject.js, this means that google gears and flash back-end stores are not enabled in my use of PerisstJS. With this setup,
localstorage becomes the first one that persist JS attempt to store data.
PersistJS uses HTML 5
localStorage DOM attribute to implement its
localstorage storage. HTML 5 is a new specification in draft state now.
localStorage is one of the two storage mechanisms introduced, which “is designed for storage that spans multiple windows, and lasts beyond the current session.” The the storage format that HTML 5 exposes are key/value pairs. Both keys and values have to be strings. For further reading, see specification draft.
If you are an Ext JS user, you can use PersistStateProvider to persist UI state and application data.