Question

My Application is designed to work offline with HTML5 appcache. Is there a way I can disable downloading appcache until the user is authenticated through the login interface? This way the appcache will be created only if a valid user accesses the page and prevent caching application to devices used by other users. Is this possible and if yes, how?

P.S. I tried the following:

$window.applicationCache.addEventListener('checking', function(event){
  event.preventDefault();
  // or
  event.abort();
}, false);

// and the following way

window.addEventListener('load', function(event) {
  window.applicationCache.addEventListener('checking', function(e) {
    window.applicationCache.abort();
      e.preventDefault();
  }, false);
}, false);

// and even this

window.applicationCache.addEventListener('downloading', function(e) {
    window.applicationCache.abort();
    e.preventDefault();
}, false);

Nothing of the above seems to work, the browser will still have appcache when its run.

Was it helpful?

Solution

I haven't tested this but I believe you can populate an application cache using an iframe. View the source of this page to see an example of this in action.

http://appcache-demo.s3-website-us-east-1.amazonaws.com/offline-iframe/

So, for your scenario, you could programmatically append an iframe with a link to your manifest only once login is complete. You could then include your login page as part of that manifest so future visits from users who had successfully logged in would work even when offline.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top