SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
Service Worker 
New game changer is coming :)
Chang W. Doh 
<hi> </hi> 
GDG WebTech Organizer 
HTML5Rocks/KO Contributor/Coordinator 
http://cwdoh.com
Offline!! App. Cache!! 
App. Cache!! 
Offline!! 
Image: ‘Mission Impossible 4’ Movie
We forgot something! 
But…what?
Mission Impossible: 
before the ‘ServiceWorker’! 
● Truely controlling offline resources 
o Application Cache? OMG! 
o Everything managed by your webbrowser! 
● Plus, background processing 
o Remote Push Notification, Alarm, 
Background-update of resources, ... 
o Everything run on your webpage!
Mission completed: 
‘ServiceWorker’ solves... 
● Truely controlling offline/network stack 
o Programmable cache control 
o Custom response 
● Plus, background processing 
o Remote Push Notification 
o Task Scheduler(e.g. Local Notification) 
o BackgroundSync 
o ...
Yay, 
ServiceWorker!!
Is Service Worker available? 
● Specification is worked in progress. But, 
o Installed 
§ https://slightlyoff.github.io/ServiceWorker/ 
spec/service_worker/ 
o Activating 
§ http://www.w3.org/TR/service-workers/ 
● See also: Is Service Worker ready? 
o https://jakearchibald.github.io/ 
isserviceworkerready/ 
http://www.slideshare.net/jungkees/service-workersa
Overview: 
● Event-driven scripts 
Service Worker 
o that run independently of web pages 
● ServiceWorker has 
o Access to domain-wide events such as 
network fetches 
o scriptable caches 
o The ability to respond to network requests 
from certain web pages via script 
§ A way for applications to "go offline" 
http://www.slideshare.net/jungkees/service-workersa
Overview: 
● Principles & terms 
Service Worker 
o Run on same origin 
o Registration keyed by URL scope 
o Document is controlled by matching 
SeviceWorker upon navigation 
o Successfully installed worker is considered 
worker in waiting 
o Lifecycle events 
o Functional events 
http://www.slideshare.net/jungkees/service-workersa
Overview: 
● Security 
Service Worker 
o Origin relativity 
o Cross origin resource 
o HTTPS only: preventing man-in-the-middle 
attacks 
http://www.slideshare.net/jungkees/service-workersa
Typical network fetch: 
Sufficient response 
http://www.slideshare.net/jungkees/service-workersa
Typical network fetch: 
Insufficient response 
http://www.slideshare.net/jungkees/service-workersa
With ServiceWorker: 
Bring your own cache 
http://www.slideshare.net/jungkees/service-workersa
With ServiceWorker: 
Fallback to network 
http://www.slideshare.net/jungkees/service-workersa
What can we do with 
ServiceWokers? 
● Eliminating loading time 
o Developer knows what is most important 
resource in our webpages. 
§ We can control ‘request/response flow’ and 
‘cache’ with ServiceWorker. 
§ and Front-end developers just write their code 
without other libraries to control cache-flow. 
o Your page will be loaded in an instant!!! 
● Other features come and see us soon. :)
How to: 
enable ‘Service Worker’ 
● Type in the url box 
chrome://flags 
or 
chrome://flags/#enable-service-worker 
● Check ‘enable’ like: 
36+
How to: 
know ‘Service Worker is working’ 
● Type in the url box: 
chrome://inspect/#service-workers 
● To see the registrations: 
chrome://serviceworker-internals
Demo from Google I/O 2014: 
Topeka
Demo from Google I/O 2014: 
● Install 
Topeka 
// ServiceWorker is ‘Installed’!!! 
this.addEventListener("install", function(e) { 
e.waitUntil( caches.create("core") // Creating Cache ‘core’! 
.then(function(core) { 
var resourceUrls = [ 
"", 
"?offline", 
"components/core-ajax/core-ajax.html", 
// ... 
]; 
return Promise.all(resourceUrls.map(function(relativeUrl) { 
// Add resource to cache ‘core’ 
return core.add(baseUrl + relativeUrl); 
})); 
}));});
Demo from Google I/O 2014: 
● fetch 
this.addEventListener("fetch", function(e) { 
var request = e.request; 
if (this.scope.indexOf(request.origin) == -1) { return; } 
// Basic read-through caching. 
e.respondWith( 
caches.match(request, "core").then( 
function(response) { return response; }, 
function() { 
// we didn't have it in the cache, so add it to the cache and return it 
return caches.get("core").then( 
function(core) { log("runtime caching:", request.url); 
// FIXME(slighltyoff): add should take/return an array 
return core.add(request).then( 
function(response) { 
return response; 
}); 
// ... 
Topeka
References 
1. ServiceWorker first draft published 
2. Specification 
3. Explainer 
4. Implemetation Considerations 
5. Service Workers: Bring your own magic 
6. Topeka Demo @Google I/O 2014

Más contenido relacionado

La actualidad más candente

System webpack-jspm
System webpack-jspmSystem webpack-jspm
System webpack-jspm
Jesse Warden
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS
偉格 高
 

La actualidad más candente (20)

Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JS
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
 
Service Worker 101 (en)
Service Worker 101 (en)Service Worker 101 (en)
Service Worker 101 (en)
 
Service worker - Offline Web
Service worker - Offline WebService worker - Offline Web
Service worker - Offline Web
 
Service worker API
Service worker APIService worker API
Service worker API
 
Node.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseNode.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash Course
 
Bower & Grunt - A practical workflow
Bower & Grunt - A practical workflowBower & Grunt - A practical workflow
Bower & Grunt - A practical workflow
 
Packing for the Web with Webpack
Packing for the Web with WebpackPacking for the Web with Webpack
Packing for the Web with Webpack
 
Service workers
Service workersService workers
Service workers
 
An Intro into webpack
An Intro into webpackAn Intro into webpack
An Intro into webpack
 
System webpack-jspm
System webpack-jspmSystem webpack-jspm
System webpack-jspm
 
Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS
 
CasperJs Enjoy Functional Testing
CasperJs Enjoy Functional TestingCasperJs Enjoy Functional Testing
CasperJs Enjoy Functional Testing
 
Puppeteer
PuppeteerPuppeteer
Puppeteer
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDB
 
"Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native ""Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native "
 
Module, AMD, RequireJS
Module, AMD, RequireJSModule, AMD, RequireJS
Module, AMD, RequireJS
 
Hitchhiker's guide to the front end development
Hitchhiker's guide to the front end developmentHitchhiker's guide to the front end development
Hitchhiker's guide to the front end development
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scripts
 
CasperJS and PhantomJS for Automated Testing
CasperJS and PhantomJS for Automated TestingCasperJS and PhantomJS for Automated Testing
CasperJS and PhantomJS for Automated Testing
 

Destacado

CyberAgentにおけるMongoDB
CyberAgentにおけるMongoDBCyberAgentにおけるMongoDB
CyberAgentにおけるMongoDB
Akihiro Kuwano
 
Mongo dbを知ろう
Mongo dbを知ろうMongo dbを知ろう
Mongo dbを知ろう
CROOZ, inc.
 
月間10億pvを支えるmongo db
月間10億pvを支えるmongo db月間10億pvを支えるmongo db
月間10億pvを支えるmongo db
Yuji Isobe
 

Destacado (20)

Service Worker 101 (한국어)
Service Worker 101 (한국어)Service Worker 101 (한국어)
Service Worker 101 (한국어)
 
インブラウザデザインについて(考察)
インブラウザデザインについて(考察)インブラウザデザインについて(考察)
インブラウザデザインについて(考察)
 
ウェブサービスのAARRR
ウェブサービスのAARRRウェブサービスのAARRR
ウェブサービスのAARRR
 
프론트엔드 개발자를 위한 크롬 렌더링 성능 인자 이해하기
프론트엔드 개발자를 위한 크롬 렌더링 성능 인자 이해하기프론트엔드 개발자를 위한 크롬 렌더링 성능 인자 이해하기
프론트엔드 개발자를 위한 크롬 렌더링 성능 인자 이해하기
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015
 
프론트엔드 개발자를 위한 크롬 렌더링 성능인자 이해하기
프론트엔드 개발자를 위한 크롬 렌더링 성능인자 이해하기프론트엔드 개발자를 위한 크롬 렌더링 성능인자 이해하기
프론트엔드 개발자를 위한 크롬 렌더링 성능인자 이해하기
 
SOSCON 2014: 문서 기반의 오픈소스 기여하기
SOSCON 2014: 문서 기반의 오픈소스 기여하기SOSCON 2014: 문서 기반의 오픈소스 기여하기
SOSCON 2014: 문서 기반의 오픈소스 기여하기
 
Ninja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for BeginnersNinja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for Beginners
 
Cache in Chromium: Disk Cache
Cache in Chromium: Disk CacheCache in Chromium: Disk Cache
Cache in Chromium: Disk Cache
 
What is next for the web
What is next for the webWhat is next for the web
What is next for the web
 
GDG DevFest 2014 - 코드 없이 오픈소스 기여하기: HTML5Rocks/KO 번역 야사
GDG DevFest 2014 - 코드 없이 오픈소스 기여하기: HTML5Rocks/KO 번역 야사GDG DevFest 2014 - 코드 없이 오픈소스 기여하기: HTML5Rocks/KO 번역 야사
GDG DevFest 2014 - 코드 없이 오픈소스 기여하기: HTML5Rocks/KO 번역 야사
 
Polymer Codelab: Before diving into polymer
Polymer Codelab: Before diving into polymerPolymer Codelab: Before diving into polymer
Polymer Codelab: Before diving into polymer
 
OVERVIEW: Chromium Source Tree
OVERVIEW: Chromium Source TreeOVERVIEW: Chromium Source Tree
OVERVIEW: Chromium Source Tree
 
Service Worker 201 (한국어)
Service Worker 201 (한국어)Service Worker 201 (한국어)
Service Worker 201 (한국어)
 
Chromium: NaCl and Pepper API
Chromium: NaCl and Pepper APIChromium: NaCl and Pepper API
Chromium: NaCl and Pepper API
 
CyberAgentにおけるMongoDB
CyberAgentにおけるMongoDBCyberAgentにおけるMongoDB
CyberAgentにおけるMongoDB
 
Mongo dbを知ろう
Mongo dbを知ろうMongo dbを知ろう
Mongo dbを知ろう
 
Yahoo Mail moving to React
Yahoo Mail moving to ReactYahoo Mail moving to React
Yahoo Mail moving to React
 
月間10億pvを支えるmongo db
月間10億pvを支えるmongo db月間10億pvを支えるmongo db
月間10億pvを支えるmongo db
 
10分で分かるr言語入門ver2.5
10分で分かるr言語入門ver2.510分で分かるr言語入門ver2.5
10分で分かるr言語入門ver2.5
 

Similar a ServiceWorker: New game changer is coming!

Rapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 PlatformRapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 Platform
WSO2
 

Similar a ServiceWorker: New game changer is coming! (20)

Building Offline Ready and Installable Web App
Building Offline Ready and Installable Web AppBuilding Offline Ready and Installable Web App
Building Offline Ready and Installable Web App
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Apps
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Apps
 
Progressive Web Apps 101
Progressive Web Apps 101Progressive Web Apps 101
Progressive Web Apps 101
 
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and ScaleGDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
GDD Japan 2009 - Designing OpenSocial Apps For Speed and Scale
 
Service workers - Forza lavoro al servizio della tua Performance
Service workers - Forza lavoro al servizio della tua PerformanceService workers - Forza lavoro al servizio della tua Performance
Service workers - Forza lavoro al servizio della tua Performance
 
PWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service WorkerPWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service Worker
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Apps
 
[1C1]Service Workers
[1C1]Service Workers[1C1]Service Workers
[1C1]Service Workers
 
Service Worker - Reliability bits
Service Worker - Reliability bitsService Worker - Reliability bits
Service Worker - Reliability bits
 
How to build a website that works without internet using angular, service wor...
How to build a website that works without internet using angular, service wor...How to build a website that works without internet using angular, service wor...
How to build a website that works without internet using angular, service wor...
 
Progressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & LearningsProgressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & Learnings
 
Building Progressive Web Apps for Windows devices
Building Progressive Web Apps for Windows devicesBuilding Progressive Web Apps for Windows devices
Building Progressive Web Apps for Windows devices
 
GDG Ibadan #pwa
GDG Ibadan #pwaGDG Ibadan #pwa
GDG Ibadan #pwa
 
APIs, now and in the future
APIs, now and in the futureAPIs, now and in the future
APIs, now and in the future
 
Sprint 17
Sprint 17Sprint 17
Sprint 17
 
Rapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 PlatformRapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 Platform
 
Docker for Development
Docker for DevelopmentDocker for Development
Docker for Development
 
Building with Firebase
Building with FirebaseBuilding with Firebase
Building with Firebase
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 

Más de Chang W. Doh

Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요
Chang W. Doh
 

Más de Chang W. Doh (14)

Exploring what're new in Web for the Natively app
Exploring what're new in Web for the Natively appExploring what're new in Web for the Natively app
Exploring what're new in Web for the Natively app
 
Kotlin의 코루틴은 어떻게 동작하는가
Kotlin의 코루틴은 어떻게 동작하는가Kotlin의 코루틴은 어떻게 동작하는가
Kotlin의 코루틴은 어떻게 동작하는가
 
Hey Kotlin, How it works?
Hey Kotlin, How it works?Hey Kotlin, How it works?
Hey Kotlin, How it works?
 
Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요
 
introduction to Web Assembly
introduction to Web Assembly introduction to Web Assembly
introduction to Web Assembly
 
PWA Roadshow Seoul - Keynote
PWA Roadshow Seoul - KeynotePWA Roadshow Seoul - Keynote
PWA Roadshow Seoul - Keynote
 
PWA Roadshow Seoul - HTTPS
PWA Roadshow Seoul - HTTPSPWA Roadshow Seoul - HTTPS
PWA Roadshow Seoul - HTTPS
 
CSS 다시 파서 어디에 쓰나
CSS 다시 파서 어디에 쓰나CSS 다시 파서 어디에 쓰나
CSS 다시 파서 어디에 쓰나
 
Natively Web App & Service Worker
Natively Web App & Service WorkerNatively Web App & Service Worker
Natively Web App & Service Worker
 
초보 개발자를 위한 웹 프론트엔드 개발 101
초보 개발자를 위한 웹 프론트엔드 개발 101초보 개발자를 위한 웹 프론트엔드 개발 101
초보 개발자를 위한 웹 프론트엔드 개발 101
 
알아봅시다, Polymer: Web Components & Web Animations
알아봅시다, Polymer: Web Components & Web Animations알아봅시다, Polymer: Web Components & Web Animations
알아봅시다, Polymer: Web Components & Web Animations
 
Web Components - Part.I, @KIG 30th
Web Components - Part.I, @KIG 30thWeb Components - Part.I, @KIG 30th
Web Components - Part.I, @KIG 30th
 
Let's contribute, HTML5Rocks/ko!
Let's contribute, HTML5Rocks/ko!Let's contribute, HTML5Rocks/ko!
Let's contribute, HTML5Rocks/ko!
 
Overview: How to Measure your WebApp
Overview: How to Measure your WebAppOverview: How to Measure your WebApp
Overview: How to Measure your WebApp
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

ServiceWorker: New game changer is coming!

  • 1. Service Worker New game changer is coming :)
  • 2. Chang W. Doh <hi> </hi> GDG WebTech Organizer HTML5Rocks/KO Contributor/Coordinator http://cwdoh.com
  • 3. Offline!! App. Cache!! App. Cache!! Offline!! Image: ‘Mission Impossible 4’ Movie
  • 4. We forgot something! But…what?
  • 5. Mission Impossible: before the ‘ServiceWorker’! ● Truely controlling offline resources o Application Cache? OMG! o Everything managed by your webbrowser! ● Plus, background processing o Remote Push Notification, Alarm, Background-update of resources, ... o Everything run on your webpage!
  • 6. Mission completed: ‘ServiceWorker’ solves... ● Truely controlling offline/network stack o Programmable cache control o Custom response ● Plus, background processing o Remote Push Notification o Task Scheduler(e.g. Local Notification) o BackgroundSync o ...
  • 8. Is Service Worker available? ● Specification is worked in progress. But, o Installed § https://slightlyoff.github.io/ServiceWorker/ spec/service_worker/ o Activating § http://www.w3.org/TR/service-workers/ ● See also: Is Service Worker ready? o https://jakearchibald.github.io/ isserviceworkerready/ http://www.slideshare.net/jungkees/service-workersa
  • 9. Overview: ● Event-driven scripts Service Worker o that run independently of web pages ● ServiceWorker has o Access to domain-wide events such as network fetches o scriptable caches o The ability to respond to network requests from certain web pages via script § A way for applications to "go offline" http://www.slideshare.net/jungkees/service-workersa
  • 10. Overview: ● Principles & terms Service Worker o Run on same origin o Registration keyed by URL scope o Document is controlled by matching SeviceWorker upon navigation o Successfully installed worker is considered worker in waiting o Lifecycle events o Functional events http://www.slideshare.net/jungkees/service-workersa
  • 11. Overview: ● Security Service Worker o Origin relativity o Cross origin resource o HTTPS only: preventing man-in-the-middle attacks http://www.slideshare.net/jungkees/service-workersa
  • 12. Typical network fetch: Sufficient response http://www.slideshare.net/jungkees/service-workersa
  • 13. Typical network fetch: Insufficient response http://www.slideshare.net/jungkees/service-workersa
  • 14. With ServiceWorker: Bring your own cache http://www.slideshare.net/jungkees/service-workersa
  • 15. With ServiceWorker: Fallback to network http://www.slideshare.net/jungkees/service-workersa
  • 16. What can we do with ServiceWokers? ● Eliminating loading time o Developer knows what is most important resource in our webpages. § We can control ‘request/response flow’ and ‘cache’ with ServiceWorker. § and Front-end developers just write their code without other libraries to control cache-flow. o Your page will be loaded in an instant!!! ● Other features come and see us soon. :)
  • 17. How to: enable ‘Service Worker’ ● Type in the url box chrome://flags or chrome://flags/#enable-service-worker ● Check ‘enable’ like: 36+
  • 18. How to: know ‘Service Worker is working’ ● Type in the url box: chrome://inspect/#service-workers ● To see the registrations: chrome://serviceworker-internals
  • 19. Demo from Google I/O 2014: Topeka
  • 20. Demo from Google I/O 2014: ● Install Topeka // ServiceWorker is ‘Installed’!!! this.addEventListener("install", function(e) { e.waitUntil( caches.create("core") // Creating Cache ‘core’! .then(function(core) { var resourceUrls = [ "", "?offline", "components/core-ajax/core-ajax.html", // ... ]; return Promise.all(resourceUrls.map(function(relativeUrl) { // Add resource to cache ‘core’ return core.add(baseUrl + relativeUrl); })); }));});
  • 21. Demo from Google I/O 2014: ● fetch this.addEventListener("fetch", function(e) { var request = e.request; if (this.scope.indexOf(request.origin) == -1) { return; } // Basic read-through caching. e.respondWith( caches.match(request, "core").then( function(response) { return response; }, function() { // we didn't have it in the cache, so add it to the cache and return it return caches.get("core").then( function(core) { log("runtime caching:", request.url); // FIXME(slighltyoff): add should take/return an array return core.add(request).then( function(response) { return response; }); // ... Topeka
  • 22. References 1. ServiceWorker first draft published 2. Specification 3. Explainer 4. Implemetation Considerations 5. Service Workers: Bring your own magic 6. Topeka Demo @Google I/O 2014