2

I'm developing a small HTML5 web application for iPad that is intended to work in fullscreen mode (ie. it has the proprietary Apple meta tag, it is added to Home Screen):

<meta name="apple-mobile-web-app-capable" content="yes" />

The application basically fetches some data via AJAX and presents it to the user. The AJAX data are external (from a different domain, different server). I have the system setup for cross-origin requests, they work in online mode. In other words: the static data lie on server A, the dynamic data - on server B.

I created a proper cache manifest file, listing all static content of the site (HTML, CSS, images, JS) and then having the NETWORK: * section at the end - this way all the dynamic content (AJAX) is always retrieved from the network. The application fails "gracefully" if the requests fail, by displaying some fake content.

With the above setup, the following happens:

  1. If I run the application while online, everything works ;)
  2. If I disable the WiFi on iPad (pure offline mode), everything works as expected - the application falls back to the offline content
  3. If I connect to the network again, but take the static-content server offline (the one that has everything cached), the application won't start; after spending a while in splash-screen, it shows me the a popup with <app> could not be opened because it could not connect to the server.; I can either choose Close or Retry.

The point 3 of the above is the one that drives me crazy because it was the only reason I started fiddling with application cache. Why doesn't the iPad web app fall back to cached content if the manifest file is not reachable? (not 404, the server is offline)

Is the answer to HTML5 iphone offline webapp completely incorrect? If not, how can I achieve this behavior on iPad?

Community
  • 1
  • 1
Neo
  • 1,176
  • 2
  • 10
  • 15

1 Answers1

1

Point 2 and 3 are completely different scenarios, so we cannot expect the same behavior.

In point 3, the device cannot fall back to the cached content when in online mode because if it do so, there will be no way to know for the user whether he is connected to the server or not.

I mean, in offline mode, the user knows it, and knows that he is with cached data. But in online mode, he expects to get the stuff from the server. If the server is not available, the user should be aware of this. If the server is not available and he is sent directly to cached data, the server error will be hidden to him, thinking that he is connected when he is actually not.

For example, web browsers can cache pages to be seen in offline mode. But if we are in online mode and try to open an unavailable page, we expect to see the error message, not a cached version of the page without any warning. We can go to offline mode to see the cached page if we want, but the correct behavior is to show the error to the user.

Alejandro Martin
  • 5,691
  • 1
  • 17
  • 21
  • 3
    If I were to open the page in online mode, I would still display the cached version of all content - because it was specified as such in the manifest file. The "dynamic content" is specified in `NETWORK:` part of manifest file. Please read about the HTML5 application cache and its behavior. The only file that the iPad could only be retrieving in scenario 3 is actually the `cache.manifest` file; I'd like to know if there is a way to set the behavior to "If the manifest file is not available, use the previous manifest file" rather than failing. – Neo Aug 18 '11 at 09:37