- Service Worker Development Cookbook
- Sean Amarasinghe
- 271字
- 2021-07-14 10:05:18
Setting up service workers
In order to get service workers running, we need to serve our code via Hyper Text Transfer Protocol Secure (HTTPS). Service workers are designed to run only across HTTPS for security reasons. Source code repositories such as GitHub support HTTPS, where you can host your files.
Getting ready
If you are using a newer version of a browser, the chances are that service workers are already enabled on it. But, if that is not the case, we will have to change few things in the browser settings. In the following section, we are going to cover how to enable service worker features in Chrome and Firefox.
How to do it...
Follow the steps below to enable service worker in Chrome and Firefox.
Chrome
To experiment in Chrome, you need to download Chrome Canary:
- Go to https://www.google.com/chrome/browser/canary.html and download the latest version.
- Open Chrome Canary and type
chrome://flags
. - Turn on
experimental-web-platform-features
. - Restart the browser.
- The following image shows experimental features on the Chrome browser, where you enable the Experimental Web Platform feature by clicking on the Enable link underneath:
Firefox
To experiment in Firefox, you need to download Firefox Nightly:
- Go to https://nightly.mozilla.org/ and download the latest version.
- Open Firefox Nightly, and go to
about:config
. - Set
experimental-web-platform-features
totrue
. - Restart the browser.
Note
At the time of writing, Opera offers partial support for service workers, including basic support, as well as installing and uninstalling events. Internet Explorer and Safari do not support service workers.
Service workers are currently an experimental technology, meaning the syntax and the behavior are subject to change in future versions as the specification changes.
- 新編Visual Basic程序設計上機實驗教程
- 計算機網絡
- Learn Blockchain Programming with JavaScript
- 騰訊iOS測試實踐
- Spring技術內幕:深入解析Spring架構與設計
- Java程序設計與計算思維
- Amazon S3 Cookbook
- 數據結構習題解析與實驗指導
- Visual Basic程序設計
- 0 bug:C/C++商用工程之道
- SQL Server 2008 R2數據庫技術及應用(第3版)
- Android應用開發深入學習實錄
- Clojure for Java Developers
- Android應用開發實戰(第2版)
- C# 7.1 and .NET Core 2.0:Modern Cross-Platform Development(Third Edition)