Search code examples
javascripthtmlweb-applicationshtml5-appcache

What happens when application cache fallback URLs are unloadable?


MDC states that the browser loads fallback files when network requests fails:

Fallback entries are used when an attempt to load a resource fails. For example, let's say the cache manifest file http://www.example.com/example.appcache includes the following content:

CACHE MANIFEST
FALLBACK:
example/bar/ example.html

Any request to http://www.example.com/example/bar/ or any of its subdirectories and their content cause the browser to issue a network request to attempt to load the requested resource. If the attempt fails, due to either a network failure or a server error of some kind, the browser loads the file example.html instead.

What happens when the fallback file is removed from the cache?


Solution

  • The fallback file will still be in the browser's application cache until you attempt an update. Once you update the manifest then the browser's attempt to update will fail, as per step 17 item 4 of the "Downloading or updating an application cache" procedure:

    If the previous step fails (e.g. the server returns a 4xx or 5xx response or equivalent, or there is a DNS error, or the connection times out, or the user cancels the download), or if the server returned a redirect, or if the resource is labeled with the "no-store" cache directive, then run the first appropriate step from the following list: [HTTP]

    If the URL being processed was flagged as an "explicit entry" or a "fallback entry"

    If these steps are being run in parallel for any other URLs in file list, then abort these steps for those other URLs. Run the cache failure steps.

    If this was an update attempt, the previous version of the cache will remain active, if it's a new attempt then nothing will be cached.