Updating appcache – Mobile Web Development

Now let’s take a look at one of the hardest things to deal with, with working with the app cache. The fact that you have to remember to update the application cache. Let’s say, we change something in our file, let’s add a title. Now, let’s save this and go back and try to reload again. Now, you’ll notice that even though I saved the index.html file Nothing happened to the cashe. It’s because the only thing that was checked was the cashe file, the manifest, and we didn’t touch the manifest at all. So let’s go back and do that now. So in the manifest, we need to do some actual change to the file. We can’t just touch it with the command line utility touch. That actually won’t trigger a reload. So let’s just add a version number hit save and now let’s go back and reload again. This time you’ll see again we’ve downloaded the cache. But remember what we are seeing here, what the user is seeing here is not actually the new content. It loaded it from the cache. And then updated the cache, not in real time, that way the user gets the content immediately, while they still get updated content. Now we can listen for the event on cache updated, and the cache update event will tell us that the user really needs to pick a good time to reload. We could surface that by popping a dialog box that says, Hey, this application is updated. Do you want to reload now? But, that can also be postponed, and you can just presume that the user will get a new version, when they hit refresh again. If I hit refresh one more time, now it’s pulling it from the cache again, and I have the updated content over here.

Be the first to comment

Leave a Reply

Your email address will not be published.