官术网_书友最值得收藏!

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:

  1. Go to https://www.google.com/chrome/browser/canary.html and download the latest version.
  2. Open Chrome Canary and type chrome://flags.
  3. Turn on experimental-web-platform-features.
  4. Restart the browser.
  5. 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:

  1. Go to https://nightly.mozilla.org/ and download the latest version.
  2. Open Firefox Nightly, and go to about:config.
  3. Set experimental-web-platform-features to true.
  4. 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.

主站蜘蛛池模板: 台东市| 梅河口市| 永新县| 闽侯县| 舞阳县| 梅州市| 开平市| 师宗县| 阳谷县| 唐山市| 勐海县| 凤阳县| 阿合奇县| 革吉县| 荥经县| 盐边县| 怀集县| 府谷县| 邯郸市| 内江市| 台江县| 南平市| 类乌齐县| 红原县| 泰兴市| 淳化县| 晋中市| 宁明县| 临沧市| 内江市| 开平市| 中宁县| 武功县| 游戏| 江山市| 共和县| 罗城| 五家渠市| 伊通| 通道| 桐梓县|