Step by step solution:
- Check if you're online/offline
- 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.
- 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..