HTML5 ApplicationCache - Can't get what I want?

I have a vBulletin install and I would like to cache the forum homepage.

What I would LIKE to have happen is:

  • Go to page, cache it
  • Return to forum homepage - show cached version while seamlessly getting a new version in the background, and when I have it… replace content

This allows the user to quickly load the forum home page and click to various sections. The main thing they would be missing out is up-to-date “last post” links, but those would update in the background as fast as it can.

This is the way GMail works for me. I load it up… and after a couple of seconds it suddenly “replaces itself” with a refreshed copy of my inbox - new messages since my last check.

How do I accomplish this? Read a number of things and demos but just having issues getting the window.applicationCache to work for me, which is new to me as a whole

You could make the manifest change (e.g. generate a random number or the current date and time in a comment in the manifest) every time it is loaded, or every time something on your site changes.

Updating the cache is expensive: everything listed in the manifest will be downloaded again, so for your use case just include the HTML file you want cached.

Alternatively you could just use normal HTTP cache (set the page to expire after a long time) and update the page with XHR. However you would only want to do this when JS is enabled or you’ll screw up users with JS disabled and also search engines.

Hmm… I am confused :frowning:

So it says:

To programmatically update the cache, first call applicationCache.update(). This will attempt to update the user’s cache (which requires the manifest file to have changed).

Well my manifest would in theory never change (or at least not every 5 minutes or so). So how can GMail and other apps cache the inbox but still update it (and update the cache) with new content in the background?

i found this. also [URL=“http://diveintohtml5.org/offline.html”]this. think it helps much?

Sounds like a waste of time to me – you’d be better off stripping out all the bloated crap that vBull wastes time on and just sending the request; sending MORE javascript at it is NOT the answer… especially since that would be supported on what, two of the four browsers MAYBE.

I mean, when a topic list page blows 116k of markup on 6k of plain text throwing more code at it for a ‘smoother’ experience is NOT the answer. You get that down to 12-15k (what it SHOULD be) and get every bit of presentation out of the markup it should load as smoothly or even smoother… Of course if it’s that new vBull 4 where it wastes 250+K on the same amount of page information using 480k of javascript and 120k of CSS (FOR WHAT!?!) you’ve got even more room to maneuver on throwing wasteful code in the trash.

Besides, showing one content and then having it change in the middle of the user navigating the page is a really bad idea. Much less I don’t even want to think about how badly that would break “forward”, “back” and middle-click like most of the “ajax for nothing” crap out there. See how webmail has been flushed down the crapper with this exact same type of nonsense.