6

By design HTML5 Offline support (AppCache) works if client device is offline or client device is online and server is accessible. After that I cached the application and reopened it in the browser (of refresh it) when the device has no internet access the browser loads the application from AppCache. In this case the browser does not try to fetch appcache manifest (it understand that we're offline).

But let's consider a case when my device is not offline. It still has internet connection. But my server is down. There could be many different reasons for this (hardware failture, AppPool stopped, IIS throttling, DNS error and so on). In this case when I open a cached application in the browser it'll try to fetch appcache manifest and gets 404 error (not found). And after that the browser clears AppCache for the app! So on the next run it won't load it from AppCache and show 404 error "page". No more offline work.

It looks strange for me that offline mode functioning depends on a reason the server isn't accessible. Why should I care as a user (it's no internet connection or server is down)?

So my question is: do anybody know any way to make an application work when a device is online but its server isn't reachable?
Ideally I should be able to catch window.applicationCache's error event and tell it "it's ok, please continute to use the cache, do not obsolete it".

Shrike
  • 9,218
  • 7
  • 68
  • 105
  • What browser, I just did this in Chrome and my cache manifest is still there. Shut down server but stayed online, got error: Application Cache Error event: Manifest fetch failed (-1) but Chrome did not delete my original manifest. – mattdlockyer Feb 06 '13 at 20:05
  • 1
    I'm using Chrome 24. I have the same behavior in last Firefox. What http status your browser is getting when you shut down your server? Mine gets 404, I see it in Fiddler. In the browser's console I see the following: Document was loaded from Application Cache with manifest http://localhost/ajax/manifest.appcache Application Cache Checking event Application Cache Obsolete event – Shrike Feb 07 '13 at 15:07
  • 1
    Any news about this? I'm facing the same problem right now. – Roland Jan 21 '14 at 10:31

1 Answers1

1

This is not possible per the application-cache specification:

Otherwise, if fetching the manifest fails in some other way (e.g. the server returns another 4xx or 5xx response or equivalent, or there is a DNS error, or the connection times out, or the user cancels the download, or the parser for manifests fails when checking the magic signature), or if the server returned a redirect, or if the resource is labeled with a MIME type other than text/cache-manifest, then run the cache failure steps.

Mike Nitchie
  • 1,166
  • 2
  • 13
  • 29