<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d8211560\x26blogName\x3dTech+Tips,+Tricks+%26+Trivia\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://mvark.blogspot.com/search\x26blogLocale\x3den\x26v\x3d2\x26homepageUrl\x3dhttp://mvark.blogspot.com/\x26vt\x3d-5147029996388199615', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Tech Tips, Tricks & Trivia

by 'Anil' Radhakrishna
An architect's notes, experiments, discoveries and annotated bookmarks.

Search from over a hundred HOW TO articles, Tips and Tricks


Client-Side Storage Options for Web Applications

There are at least 10 ways to persist user state in an ASP.NET application.

There are also client-side storage options:
  • Cookies - useful for storing text up to a size of 4KB. Most browsers allow 20 per domain
  • Web Storage (includes sessionStorage & localStorage) - most browser implementations give you between 2MB and 5MB of key/value storage  per domain.
  • Indexed DB - is also a key/value store but it allows persistence of JavaScript objects unlike Web Storage which allows only (UTF-16) strings.
  • FileSystem API - supported by Chrome 27+, Opera 15+ and Blackberry 10

Out of these only the first 2 more types - Cookies and Web Storage, are supported by all modern browsers. You can consider using the other two if your application does not need to be cross-browser.

Cookies and Web Storage can be valuable in some scenarios but the biggest drawback with client-side storage options is that the data is not truly persistent as the user can nuke it at any time.

Moreover, like cookies, Web Storage can be blocked. In Chrome, you have to click the Wrench and choose Options, go to the Under the Hood tab, select Content Settings, and choose the Block any sites from setting data option:


Labels:

Tweet this | Google+ it | Share on FB

« Home | Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »

»

Post a Comment