Tolerating Network Instability
Service workers allow web applications to boot nearly instantly, regardless of whether the network connection is slow or completely absent! We'll begin with recipes for HTTP caching, and then get some serious practical experience with service workers. We'll combine FIVE great caching strategies, to achieve an optimum balance between data that's as fresh and instantly available as possible.
Tolerating Network InstabilityHTTP Caching
We'll look at the basic HTTP caching we've been using for decades, and outline two strategies for success:
- Immutable Content - Where content at a URL never changes,
- Mutable Content - Where we rewrite content at URLs, and rely on
ETagheaders to detect modifications.
Tolerating Network InstabilityUsing Appcache (responsibly)
We'll go over the basics of the first widely-applied technology for building offline-capable web apps. Appcache is known for its temperamental behavior, and its ability to almost solve the problems we need it to solve. We'll review a strategy for minimizing risk and maximizing benefit -- ultimately delivering a fast return-visit experience for those browsers that don't yet support more modern approaches.
Tolerating Network InstabilityEXERCISE: Appcache
We'll add an Appcache Manifest to our single page app, allowing browsers to download the complete application in the background on users' first visit.
Tolerating Network InstabilityService Workers
Service workers are programmable network proxies that can be installed on our users' browsers. Rather than providing us with a turnkey solution to the "offline problem", service workers expose a set of primitives that we can use to build our own solution. We'll dive deep into the worker registration process and lifecycle, discuss several different categories of resources, and provide an optimal caching strategy for each category!
Tolerating Network InstabilityLUNCH
Break for Lunch
Tolerating Network InstabilityEXERCISE: Service Workers I
We'll apply our newfound knowledge of service workers, in order to greatly improve the "time to first paint" and "time to interactive" of our app for return visits.