webofflineoffline-cachingapplication-cacheservice-worker

Best Approach Today for Offline Web Apps


I'm trying to build a web app that needs to work offline at times. The standard approach until now has been to use the browser's Application Cache. However, it appears that Application Cache is deprecated and will be removed from browsers in the future (see https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache). The recommendation is to use Service Workers. However, Service Workers is not currently fully supported in all browsers.

So, what to do? What is the best way, today, to go about building an offline web application, considering the current state of Application Cache and Service Workers? Are there other approaches that are less reliant on browser features?


Solution

  • 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.

    Source: https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API#compat-mobile

    Chrome Issue: https://crbug.com/410665

    Personally, I wouldn't bother with AppCache unless offline is a main part of the app.