Book Image

Service Worker Development Cookbook

By : Sean Amarasinghe
Book Image

Service Worker Development Cookbook

By: Sean Amarasinghe

Overview of this book

It would be nice to have web apps that work offline and send push notifications. This is now possible with Service Workers, which can add native-like functionality to your web apps without requiring a download. This book will get your mobile and web apps functioning without Internet connectivity, improve performance and network interaction in order to increase the level of availability, and show you how to build performant applications that seamlessly integrate with third-party APIs. We’ll show you how to add Service Worker functionality to web apps and sites, access offline content through basic and advanced techniques, and build powerful interactive system notifications. We’ll also teach you about cache functionality and assets to provide immediate load even over narrow connections. We conclude by giving you various tips to improve app performance, including the background sync technique. By the end of this book, you’ll know build high performing and faster web and mobile applications with Service Workers.
Table of Contents (17 chapters)
Service Worker Development Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Setting up GitHub pages for SSL


Service workers are designed to run only across HTTPS. So, in order for us to test our code, we need our web pages to be delivered across HTTPS. GitHub pages are served across HTTPS and it's free to use. So let's get on with it.

Getting ready

Before registering for a GitHub account, please make sure you have a valid e-mail address.

How to do it...

Follow these instructions to set up GitHub pages:

  1. Head over to GitHub (https://github.com) and register yourself to obtain an account, if you don't have one already.

  2. Once you have done that, log in and create a new repository with the following format:

    username.github.io, where username is your username.

    If the first part of the repository doesn't match your username exactly, it won't work.

  3. Open your command-line window and clone your repository.

    $ git  clone https://github.com/username/username.github.io
    
  4. Change the directory to username.github.io:

    $ cd username.github.io
    
  5. Create a directory called service-workers:

    $ mkdir service-workers
    
  6. Create an index.html file with some text:

    $ echo "Service Workers" > index.html
    
  7. Now let's commit and push our changes to the repository:

    $ git add --all
    $ git commit -m "initial commit"
    $ git push -u origin master
    
  8. Open up a browser and go to http://username.github.io/service-workers/.