Monday, 25 February 2008

Isolated Storage in Silverlight 2

I have updated this slightly (as this was originally written prior to the release of Silverlight 2), but I will do a more indepth article on isolated storage in the future.

100Kb Default Limit

It looks like (via ScottGu's blog), that there will be no increase in the size of isolated storage for Silverlight 2 Beta 1, infact it's now less (silverlight 1.1 was 1Mb). I think it's unlikely that this will increase to drastically in the future (in fact since it has been reduced, it indicates the direction).

My opinion won't be very popular but here we go.
In the past I have been someone who has publicly stated that we need a large default, but i now believe i was wrong. If the default was 100Mb, I am not sure after visiting 10 sites, I would want 1GB of my hard disk taken up.

User Configurable Limit

the good news is that for those folks who need more than 100Kb, this limit is user configurable. So if you need to use more than 100Kb that you will need to ask your users to increase the limit.

Cache Volatile
In Silverlight 1.1 Data stored in Isolated Storage was volatile, so when you clear your browser cache, your isolated storage is also cleared. This has changed in the beta (and it is now stored on your local file system independant of your browser cache). However a user can just go and delete data therefore we need to ensure data is synchronised with the backend server (which means that you need to keep bandwidth in mind).

As a user I am not sure I would be too happy with losing my vital data because it wasn't saved back to the server or with using an internet application that i couldn't use throughout the world (due to my data sitting on my local file system), hence why synchronization is important.

So what should we be storing in the isolated storage?
I believe the point of the isolated storage area is to enhance the UI experience not detract from it, so I genuninely believe that I was wrong, and that Microsoft are right and low limits are sensible (with the flexibility of allowing the user to increase it).

There is no point storing media files in Isolated Storage as the browser already has a perfectly adequate caching mechanism. There is also no point keep vital documents (that are not saved back to the server) for the reasons above.

I believe isolated storage is really about 2 things:


  • Accessing / storing common data to reduce frequency of server calls

  • Temporary storage of data which is synchronised with the back end server.


Good uses of Isolated Storage

To give a flavour of what Isolated Storage should be used for I have given some examples below (this list is by no means exhaustive)


  • Displaying user details in the site e.g. "Hello Bob, Welcome Back Bob"

  • Storage of theme / skin preferences (so when you return to a site, you can see the site with your preferred skin without waiting for a response from the server first).

  • Temporary storage area for document drafts, prior to synchronisation with the server (very useful if internet coverage is flaky)



Bad uses of Isolated Storage

  • The only storage place of every vital document i have ever written

  • Attempting to store the entire contents of wikipedia



The point is if you wish to be a naughty programmer and waste your users hard disk space, you are going to have to ask them very nicely. This is not to say you can't use Isolated Storage in genuine (and innovative ways), you just need to have your users give you permission.

What is more likely to happen (with low default limit) is that there is a better chance that you will enhance the UI experience (and be respectful of hard disk space, and bandwidth), and not degrade it.

If Microsoft can fit Silverlight 1.0 in a 1MB download, and Microsoft can fit Silverlight 2, in a 4MB download, do we really need a 100MB default isolated storage limit.

4 comments:

pkr said...

I think the main problem with Silverlight's Isolated Storage story is that it is tied with the browser cache. "Normal" isolated storage is held under your user storage. If you run out of space (or quota) then your application you deal with it gracefully. Forcing a limit (even with some concept of configuring it) just seems wrong and limiting. Worring that every Silverlight application will fill Isolated Storage feels a bit like worrying that every desktop application you use will fill the disk space. I think the better solution would be to allow the browser to request that the user confirms the save (therefore to "normal" isolated storage or non-prompt (small preference info) into the 1Mgb quoted cache space. That way we can deliver application with true documents without the user worrying that rougue apps will clog up their disks. Of course this is from a Windows bias, but OSX/Linux both have the concepts of user stores too.

chrishayuk said...

Paulio,

I understand where you are coming from however I don't think it is just about rogue applications.

As I said in my post, i previously believed that I wanted a large isolated storage area and have since changed my mind on this.

I believe the intended usage of Isolated Storage is not about storing user documents locally, it is about reducing network traffic and improving user experience.

For your scenario (if you don't want to store the documents on the server), I think it would be useful to have the ability to store documents back to the file system (and I believe this is something being considered (assuming the security is nailed down)), which fits in with your user store scenario.

However I do not believe that isolated storage should be used for storing user documents, generally anything stored in isolated storage should also be stored on the back end server (or considered as temporary and volatile). The isolated storage could be used for keeping drafts before you submit your changes back to the server, but not as your main file system.

I don't think it wrong and limiting, I think we just differ on how we think Isolated Storage should be used.

I have no issue about being able to transfer documents out of the sandbox, and onto your filesystem (assuming security is nailed down, and is via save dialogs), I just have an issue with applications inapproriately using the Isolated Storage area.

Donny V said...

I like the limit because than I can offer a free version with limited storage space and than a enterprise version that syncs back to a server. It makes sense to me.

Jim said...

Where does it say that IsolatedStorage will be cleared wtih the browser cache? I don't believe anyone at Microsoft has said that (At least I can't find it).

The whole purpose of IsolatedStorage was to persit data on the client without having to worry about losing it when the user clears the cache. This would defeat the purpose entirely.

Furthermore, IsolatedStorage is stored in a folder that IE wouldn't touch when clearing the browser cache.

Can you please check your sources and update your blog?

PS: I have tested this out on a Silverlight application and the IsolatedStorage settings do persist even after I clear my cache.

Thanks