Check out a free preview of the full Progressive Web Applications and Offline course:
The "Problems with App Cache" Lesson is part of the full, Progressive Web Applications and Offline course featured in this preview video. Here's what you'd learn in this lesson:

To work around Safari's lack of support of Service Worker reviews how an alternative with App Cache might be used and the problems associated with this approach.

Get Unlimited Access Now

Transcript from the "Problems with App Cache" Lesson

>> Steve Kinney: Let's talk about, for a second, how we used to do these kind of things. You might have noticed a somewhat of an inside joke as we've gone through the day, which is kind of not being particularly nice to AppCache. There is still a compelling reason why you might consider using AppCache.

[00:00:18] If you look about service worker enthusiasm, you see a lot of green, you also see one yellow one. Which is, Safari is a not unpopular mobile browser, right, it is installed on every iPhone. If you say, I'm going to install Chrome on my iPhone, well, Apple's policies say that you still have to use Safari under the hood, so Chrome on the iPhone is Safari in Chrome clothing.

[00:00:45] So still the same rendering engine, so it's not just like, I'll have my users install Chrome, and they will have progressive web apps, it's still Safari. So there is an idea where we might want to go ahead and like, I'm gonna implement AppCache. And the way you do that, is you create this thing called a manifest, the manifest talks about all of the files that you would like to have cached, seems legitimate, right, and like maybe a fall through to the network.

[00:01:12] Aversion, this seems like okay I can just do this and I'll support everything right? Everything will be great, here we'll cache app.css, we'll cache app.js, everything else will go through the network, we can actually have fallbacks. So if they try to go to download-virus.html, we will fall back to not-available.html, we can have a fallback image.

[00:01:37] Seems like I could just do this, and skip everything Mike and Steve just showed me for the last two days.
>> Steve Kinney: Just for fun, when you get home, you can Google Jake Archibald, we've mentioned him a few times today. He's one of the developer advocates pushing service worker and AppCache.

[00:01:55] And you'll find an insightful article that, I won't say the title of in front of present company. So some tasting notes though, even the HTML page isn't listed in the manifest.
>> Steve Kinney: That one isn't there, the page that associated become part of it as well, so it kind of grows to expand everything in there.

[00:02:18] Anything in the AppCache is cache-only, even if you're on a network. So if you think about that first example, that Mike showed, where it's like, no matter what we go to cache, Mike has been a very good job today saying we are biased towards fresh data. AppCache does not share that bias with you or that opinion, if something is cached, that is it.

[00:02:40] The cache will only update if the text of the manifest is changed. That's why when you saw what we showed before there was that v1, basically the way you update that manifest is you just change that to some other number, right? And as long as any change, that will change the manifest, but other than that, that user will have whatever was in there forever.

[00:03:02] But even if you remove that, if you still have something to the regular HTTP cache, all right, we saw like you can say max age a year. You're not necessarily going to get the newest version, you could get some other one that's already in HTTP cache. And now you've changed the number, you don't know which users got the fresh data and which ones didn't.

[00:03:24] The manifest could get cached as well, at which point they wouldn't get a new manifest anyway. Because they'll go to get a manifest they'll get the HTTP cached one, which they will have the same number and they won't save the new one in that case. Non cached assets will not load at all, unless you accept them from the manifest even if you're online.

[00:03:45] And there's no logic for them to fallback if you aren't online the resources they're accepted in that network they're just not available, and they will just fail to load. The most compelling reason why you might not want to use AppCache, is this is the Mozilla documentation page for it, and you can see a few things.

[00:04:02] One is that it is deprecated and it gets the thumbs down emoji. And if you kind of look towards the lower right there, you'll also see that using application caching feature described here at this point is highly discouraged. And it goes on to say use Service Workers instead, right?

[00:04:22] A lot of what we did in Service Worker was learning from some of the problems that came from, we'll just give you this very simple file where you have no introspection, and no programmatic access, and no ability to control things. And well-meaning people tried to get it right, but it's impossible to know all the details of your application, all right, and that's a lot of the power we see in these newer APIs.