0

I want to use browser local-storage in my web application to store footer that is coming from database. I want that if data is already in local-storage then hit should not go to database.

So here my question is that how much contents I can save with local-storage?

I am planing it to use at more places in my website where html contents are coming from database.. Are there any limitations?

If yes then how i can check that localstorage is full?

Code I am using here

if (typeof (Storage) !== void (0)) {
                var key = "footer";
                if (localStorage[key] != undefined && localStorage[key] != "") {
                    BuildFooter(localStorage[key]);
                    return;
                }
else {
//Get from database
}}

Thanks Dalvir

Dalvir Singh
  • 423
  • 3
  • 11
  • 25
  • What happens when the database contents change but they already have some old data stored in local storage? You'll either have to check to see if the data has changed each time - in which case the whole thing just seems overly complicated, may as well just load the data every time - or accept that you'll have people seeing massively different versions of your site's footer (which doesn't seem like it should be an acceptable situation). – Anthony Grist Jul 30 '15 at 11:03
  • Why do you need to check whether it's full or not? Just _try_ to write your data and _catch_ an exception if it's fired. – Ivan Jul 30 '15 at 11:04

0 Answers0