Reports of Application Cache’s early demise are false. Application Cache (a.k.a Cache Manifest and AppCache) isnât perfect, it can be very frustrating to get working and many people hateÂ it with passion, but the fact is that the API will be around for the foreseeable future. I’ve been getting many questions, so this blog post is an attempt to shed some light on a confusing topic.
Mozilla says Application Cache is deprecated and unstable, WTF?
First, let’s review what Mozilla is saying about Application Cache since the majority of questions I get come from what they are saying. Mozilla has some fairly strong wording on their developer site, you can read all about it here. Or, if you donât feel like following a link, hereâs the official text from Mozilla Developer Network (MDN) website. I added the underlines toÂ emphasizeÂ wording thatâs tripping people up:
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.
Using the application caching feature described here is at this point highly discouraged; itâs in the process of being removed from the Web platform. Use Service Workers instead. In fact, as of Firefox 44, when AppCache is used to provide offline support for a page a warning message is now displayed in the console advising developers to use Service workers instead (bug 1204581).
Mozilla also references the Web Hypertext Application Technology Working Group’s (WHATWG) position on Application Cache. But,Â their wording is similar but definitely different in meaning from the WHATWG statement in their HTML Living Standard, Section 7.7. You may want to read this several times:
This feature is in the process of being removed from the Web platform. (This is a long process that takes many years.) Using any of the offline Web application features at this time is highly discouraged. Use service workers instead.
An oversimplified description of the WHATWG is itâs an organization that provides research and makes recommendations to the W3C â World Wide Web Consortium. Itâs the W3C that finalizes recommendations and makes them into standards.
Also note: Application Cache is, for the moment, still officially part of the latest draft of the WHATWG HTML Living Standard documentÂ as shown hereÂ in Section 7.2.2 (it’s a big document, it’s best to just search for application cache).
What is the true state of Service Workers?
Reality is always nuanced when it comes to cross-browser web application development. Hereâs a summary of factsÂ for cross-browser developers to consider (as of February 1, 2016):
- Service Workers are NOT supported on the following platforms, and you’ll need to use Application Cache if it suits your requirements and any Application Cache bugs don’t adversely affect your apps. You can verify these on caniuse.com.
- Android Browsers at v4.4.4 and older (there are still a lot of phones out there using older browsers). Yes, a percentage of these users download Chrome. However, as of Feb 1, 2016, Android is reporting that v4.1.x thru v4.4 represents 60.8% of all phones in circulation.
- Desktop Safari
- iOS Safari
- IE and Edge â donât forget that a lot of offline field worker apps are built specifically for laptops.
- The Service Worker specification is still a Working Draft according to the W3C. Itâs not final according to the official standards bodies. Mozilla even lists Service Workers as âExperimental Technologyâ. You can view that yourself here. Hereâs MDNsÂ wording copied directly from their webpage:
This is an experimental technologyÂ
Because this technology’s specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.
- Service workers are more complex and require coding skills in comparison to Application Cache which requires only a configuration file and one line of HTML code. Here’s an example. Itâs going to be a big step for long time Application Cache developers to wrap their heads around using Service Workers. Itâs a very powerful API but itâs not going to be as easy asÂ simply swapping out your Application Cache for offline capabilities built on Service Workers.
What to do, what to do?
My thoughts are MDNsÂ statement leaves developers between a rock and a hard place, and holds the most water if the ONLY web browsers you need toÂ support are browsers that have implementedÂ all aspects of Service Workers that meet your requirements. You’ll also need to keep in mind that Service Workers are in beta so they can also can break or not work as expected, and there is a remote possibilityÂ the functionality couldÂ change.
When you combine MDNâs statement with the WHATWG statement and the WHATWG Living Standard documentÂ the picture becomes moreÂ clear. Hereâs my interpretation: Application Cache is going to be around for a while longer.Â However, it would be a really good idea for you, as a cross-browser developer, to keep your eye on the progress of Service Workers and to consider using them in applications if/when it makes sense based on requirements and browser capabilities.
Don’t throw away an working/stable code built on Application Cache just yet. Â If you are building apps on platforms that don’t support Service Workers then Application Cache may be your only viable alternativeÂ until you can upgrade to newer platforms or other browsers.