Application Cache or Service Workers - which to use in 2016/Q2?

Ben Davison picture Ben Davison · Apr 19, 2016 · Viewed 7.8k times · Source

Quick question for discussion really, as I wanted to have input from different people.

I am in the process of developing a web page app that must be available offline.

Now to do this, as I understand it, you would go about using either the application caching feature or by using service workers.

However, here is the conundrum I have. When researching the application cache, the MDN clearly states:

Deprecated:
This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Do not use it in old or new projects. Pages or Web apps using it may break at any time.

After which another dialog box suggests using service workers instead.

The Service Workers page then goes on to state how Service Workers are an experimental technology, and it is best to consult the compatibility table.

The compatibility table says that Safari and Internet Explorer do not support Service Workers. Further consulting this site and assuming it is accurate, it states that work has begun by Microsoft to integrate service workers, however for Safari they are "Under consideration" with " Brief positive signals in five year plan."

Now this is a concern for the current project as it is essential that it be safari compatible, however, I also do not want it to break in other browsers.

What would be your recommendations? Simply go with the older Application Caching and update in the near future? Determine the users browser and act appropriately? Or, is there another way I am missing?

Answer

Daniel Herr picture Daniel Herr · Apr 19, 2016

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