Stuart shows you how you use service workers in your Django applicattions, which can have a serios beneficial impact on your users' experience. As well as the site continuing to work, service workers can improve your site's performance and bandwidth usage.
Adding a service worker to your site—to make it work offline, or to make it a full PWA—can seriously help your users’ experience. A site which works offline isn’t vulnerable to suddenly not working if their train goes into a tunnel, for example. Additionally, there’s less of a concern about your JavaScript not loading, and it can seriously improve your site’s performance and bandwidth usage.
Your service worker is a JavaScript file which has access to certain privileged functions, and one of the main things it can do is enable your site to work offline by intercepting requests for HTML pages and page dependencies (CSS, JavaScript, images, and so on), and serving cached versions of those pages instead of (or as well as) the versions from the network. Thus, if the user is offline—for extended time, if they’re somewhere without wireless, or temporarily, as they step with their phone into an elevator—your site still works with no interruptions, because the cached versions of your pages are used.
In this tutorial, Stuart shows you how to add a simple service worker to your Django site, and then moves beyond the basics to show hwo you can achieve background sync.
Unlimited access to this title and 600+ others in our library
New titles added frequently
Cancel anytime