1

I'm developing web apps using jQuery Mobile. These apps use a database to get prices, etc (using php). I'm also using appcache to be able to use the apps offline.

<html manifest="manifest.appcache">

This is all working perfectly. But when I'm online, I don't want the apps to use the appcache. How do I do that?

I can check wether I'm online/offline by checking if a file is available:

$.ajax({
    url:'http://someurl.com/online.txt',
    type:'HEAD',
    error: function()
    {
        console.log('offline');
    },
    success: function()
    {
        console.log('online');
    }
});

However I can't find anything to have the page not use the appcache..

Am I missing something?

5
  • How is the app using apache? Can you show the calls to the server? Commented Oct 17, 2013 at 12:29
  • I don't have access to the server. But does apache have anything to do with this? Commented Oct 17, 2013 at 12:32
  • I dont understand "when I´m online, dont use apache"..how can you use an apache web server when you´re offline? Commented Oct 17, 2013 at 12:35
  • I'm talking about appcache (application cache), not apache ;) Commented Oct 17, 2013 at 12:37
  • lol. sorry cant help you right now. I think I should go to bed. Commented Oct 17, 2013 at 12:38

1 Answer 1

1

Step by step solution:

  1. Check if you're online/offline
  2. If you're online, run a php script which adds a # at the end of the appcache manifest. This is because the cache will be updated if the manifest has changed.
  3. Swap the cache and refresh the page

After i finally got it working i noticed it didn't work in Firefox because of the swapCache() function. (https://bugzilla.mozilla.org/show_bug.cgi?id=769171) Lucky me my users don't use Firefox..

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.