Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ServiceWorkerの開発 / ServiceWorker Development

ServiceWorkerの開発 / ServiceWorker Development

2019年にお話させていただいたServiceWorkerの開発に関する発表の資料です。部分的に(あるいは全体的に)情報が古くなっている可能性がありますのでご了承ください。

Sho Miyamoto

June 01, 2019
Tweet

More Decks by Sho Miyamoto

Other Decks in Technology

Transcript

  1. - ٶຊ ক (Sho Miyamoto) - @shqld (Github) - @webseals

    (Twitter) - Edge / Server / Client - Իָ - τϥϯϖοτ(JazzFunkܥʣɺϐΞϊ - ౦ೆΞδΞʹॅΈ͍ͨ ͩΕʁ
  2. SW͕ൃՐ͢ΔΠϕϯτʹ͸2छྨ͋Δ - Lifecycle Events - oninstall - onactivate - Functional

    Events - onfetch - onmessage - …etc. ϥΠϑαΠΫϧ Πϕϯτ
  3. ίϯτϩʔϧ = ͋Δworker͕Functional Events ΛϋϯυϧͰ͖Δ ⾠ activeͳworker !== controller ϒϥ΢βʹΠϯετʔϧ͞ΕΔSW͸ෳ਺͋Δ

    - ผυϝΠϯ - ಉҰυϝΠϯ - ผείʔϓ - ಉҰείʔϓ શ͕ͯউखʹಈ͍͍ͯͨΒࠔΔ ίϯτϩʔϧ
  4. ίϯτϩʔϧ ίϯτϩʔϥ ͷ੾ΓସΘΓ WorkerB /b/ PageA /a/index.html WorkerA /a/ PageB

    /b/index.html φϏήʔγϣϯϦΫΤετؚΊͯ WorkerB͕ίϯτϩʔϧ
  5. είʔϓ είʔϓΛ ࢦఆ͢Δ Script Path navgator.serviceWorker .register({ scope }) e.g.

    /static/sw.js `Service-Worker-Allowed` e.g. / e.g. /, /any/
  6. navigator.serviceWorker.register()ͷҾ਺Φϓγϣϯ `imports`: - τοϓϨϕϧ: 24࣌ؒ - Πϯϙʔτ: HTTP Ωϟογϡ༏ઌ `all`:

    - τοϓϨϕϧ: HTTP Ωϟογϡ༏ઌ - Πϯϙʔτ: HTTP Ωϟογϡ༏ઌ `none`: - τοϓϨϕϧ: 24࣌ؒ - Πϯϙʔτ: 24࣌ؒ SWࣗମͷΩϟογϡ updateViaCache cf. https://developers.google.com/web/updates/2018/06/fresher-sw
  7. - Offline mode - Update on reload - Bypass for

    network - Preserve log - Switching frames - Hard reload ։ൃ࣌ͷTips
  8. - Google WebFundamentals - ϥΠϑαΠΫϧ - Workerͷίϯτϩʔϧݖ - είʔϓ -

    SWࣗମͷΩϟογϡ - NavigationPreload - Ωϟογϯάͷछྨ - ։ൃ࣌ͷTips ·ͱΊ