htmlservice-workeroffline-cachingcache-manifestbrowser-feature-detection

Fallback to manifest file if support for serviceworkers is not supported


I am making an app which will support the "Add to Homescreen" features in Android Chrome and iOS Safari. Since I would like universal offline support for both of these features, but I only want to use the manifest file where I have to, in order increase my control. However, iOS Safari does not support service workers, so my question is how can I only instantiate a cache manifest file if support for Service Workers is not present, more specifically; I know I could add manifest='whatever.appcache' to the <html> tag with JavaScript, but will browsers, specifically iOS Safari, use that cache?


Solution

  • According to an answer by @Daniel Herr:

    You could choose to use Service Workers and AppCache on the same web app. What happens in such a case is that browsers that don’t support Service Workers will use AppCache, and those that do will ignore the AppCache and let the Service Worker take over.

    Sources: https://www.w3.org/TR/service-workers/#activation-algorithm, https://crbug.com/410665

    Thanks for your answer!