SlideShare a Scribd company logo
Intro to Service Worker
API and its use cases
Satej Kumar Sahu
Mindfire Solutions
Contents
• What is a Service Worker?
• Service Worker concepts
• Promise concept
• Some general pointers
• Service Worker example
• Debugging tips
• Service Worker Support
• Service Worker use cases
• Conclusion
What is a Service Worker?
• At it’s simplest it’s a worker.
• A worker is a JavaScript script that runs in the
background, independently of other scripts in a separate
thread, without affecting the performance of the page.
• A service worker is run in a worker context: it therefore has
no DOM access, and runs on a different thread to the main
JavaScript that powers your app, so it is not blocking. It is
designed to be fully async; as a consequence, APIs such
as synchronous XHR and localStorage can't be used
inside a service worker.
Service Worker Concepts
• Worker
• Promise
• Registration
• Install
• Activate
Intro to Service Worker API and its use cases
Promise concept
• Promises are a great mechanism for running async operations
• sync
try {
var value = myFunction();
console.log(value);
} catch(err) {
console.log(err);
}
• async
myFunction().then(function(value) {
console.log(value);
}).catch(function(err) {
console.log(err);
});
• There have been various attempts to create
technologies to solve this problem
• There still isn’t a good overall control mechanism for
asset caching and custom network requests.
• AppCache — seemed to be a good idea because it
allowed you to specify assets to cache really easily.
But it relied on many assumptions and when you
didn’t follow them, it breaks.
Some general pointers
• As of Firefox 44, when AppCache is used to provide offline support for a page a
warning message is now displayed in the console advising developers to use
Service workers instead.
• Offline first experience. Native Apps already provide them so they are much
favoured.
• Many service workers features are now enabled by default in newer versions of
supporting browsers.
• If still not working, then please try
- Firefox Nightly: about:config -> dom.serviceWorkers.enabled to true -> restart
- Chrome Canary: chrome://flags -> turn on experimental-web-platform-features ->
restart
- Opera: opera://flags -> enable Support for ServiceWorker -> restart
• Service Workers are restricted to running across HTTPS for security reasons.
Service Worker example
• Service Worker presence. If not present then
fallback to other ways AppCache, indexed DB etc.
else load from network.
• Basic Architecture
• Registering a Service Worker
• Install and Activation process
• Cache control and custom responses
Intro to Service Worker API and its use cases
Intro to Service Worker API and its use cases
Debugging tips
• Chrome has chrome://inspect/#service-workers, which shows current
service worker activity and storage on a device
• chrome://serviceworker-internals, which shows more detail and allows
you to start/stop/debug the worker process
• In the future they will have throttling/offline modes to simulate bad or
non-existent connections, which will be a really good thing.
• Firefox: You can navigate to about:serviceworkers to see what SWs
are registered and update/remove them.
• When testing you can get around the HTTPS restriction by checking
the "Enable Service Workers over HTTP (when toolbox is open)" option
in the Firefox Devtools options (gear menu.)
Service Worker Support
• https://jakearchibald.github.io/isserviceworkerready/
• caniuse.com/#feat=serviceworkers
Service Worker use cases
• Caching
• Loss of connectivity. Offline user experience
• Background data synchronization
• Responding to resource requests from other origins
• Receiving centralized updates to expensive-to-calculate data such as geolocation or gyroscope, so
multiple pages can make use of one set of data
• Client-side compiling and dependency management of CoffeeScript, less, CJS/AMD modules, etc.
for dev purposes
• Hooks for background services
• Custom templating based on certain URL patterns
• Performance enhancements, for example pre-fetching resources that the user is likely to need in the
near future, such as the next few pictures in a photo album.
Example
• Gmail offline exp.
Conclusion
• Offline first experience for a better user experience
• Caching and data bandwidth usage reduction.
References
• https://developer.mozilla.org/en-US/docs/Web/API/Servic
• https://developer.mozilla.org/en-
US/docs/Web/API/Service_Worker_API/Using_Servi
ce_Workers
Any?
Ad

More Related Content

What's hot (20)

Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object Pattern
Dante Briones
 
AngularJS and Protractor
AngularJS and ProtractorAngularJS and Protractor
AngularJS and Protractor
Filipe Falcão
 
Lean Quality & Engineering
Lean Quality & EngineeringLean Quality & Engineering
Lean Quality & Engineering
Mek Srunyu Stittri
 
UI Testing Automation
UI Testing AutomationUI Testing Automation
UI Testing Automation
AgileEngine
 
Test Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and CucumberTest Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and Cucumber
Rhoynar Software Consulting
 
Better Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component PatternBetter Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component Pattern
Sargis Sargsyan
 
Automation Frame works Instruction Sheet
Automation Frame works Instruction SheetAutomation Frame works Instruction Sheet
Automation Frame works Instruction Sheet
vodQA
 
Perils of Page-Object Pattern
Perils of Page-Object PatternPerils of Page-Object Pattern
Perils of Page-Object Pattern
Anand Bagmar
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
Shailendra Chauhan
 
ProtractorJS for automated testing of Angular 1.x/2.x applications
ProtractorJS for automated testing of Angular 1.x/2.x applicationsProtractorJS for automated testing of Angular 1.x/2.x applications
ProtractorJS for automated testing of Angular 1.x/2.x applications
Binary Studio
 
Angular js automation using protractor
Angular js automation using protractorAngular js automation using protractor
Angular js automation using protractor
Ravi Gupta
 
Bdd with Cucumber and Mocha
Bdd with Cucumber and MochaBdd with Cucumber and Mocha
Bdd with Cucumber and Mocha
Atish Narlawar
 
Insights on Protractor testing
Insights on Protractor testingInsights on Protractor testing
Insights on Protractor testing
Dejan Toteff
 
Protractor training
Protractor trainingProtractor training
Protractor training
Sergiy Stotskiy
 
Fabulous Tests on Spock and Groovy
Fabulous Tests on Spock and GroovyFabulous Tests on Spock and Groovy
Fabulous Tests on Spock and Groovy
Yaroslav Pernerovsky
 
Brace yourself from automation death trap
Brace yourself from automation death trapBrace yourself from automation death trap
Brace yourself from automation death trap
Prasad Kalgutkar
 
Test Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEMTest Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEM
Sagar Sane
 
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR Meetup
 
Behaviour driven development aka bdd
Behaviour driven development aka bddBehaviour driven development aka bdd
Behaviour driven development aka bdd
Prince Gupta
 
Protractor: Tips & Tricks
Protractor: Tips & TricksProtractor: Tips & Tricks
Protractor: Tips & Tricks
Sergey Bolshchikov
 
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object Pattern
Dante Briones
 
AngularJS and Protractor
AngularJS and ProtractorAngularJS and Protractor
AngularJS and Protractor
Filipe Falcão
 
UI Testing Automation
UI Testing AutomationUI Testing Automation
UI Testing Automation
AgileEngine
 
Better Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component PatternBetter Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component Pattern
Sargis Sargsyan
 
Automation Frame works Instruction Sheet
Automation Frame works Instruction SheetAutomation Frame works Instruction Sheet
Automation Frame works Instruction Sheet
vodQA
 
Perils of Page-Object Pattern
Perils of Page-Object PatternPerils of Page-Object Pattern
Perils of Page-Object Pattern
Anand Bagmar
 
ProtractorJS for automated testing of Angular 1.x/2.x applications
ProtractorJS for automated testing of Angular 1.x/2.x applicationsProtractorJS for automated testing of Angular 1.x/2.x applications
ProtractorJS for automated testing of Angular 1.x/2.x applications
Binary Studio
 
Angular js automation using protractor
Angular js automation using protractorAngular js automation using protractor
Angular js automation using protractor
Ravi Gupta
 
Bdd with Cucumber and Mocha
Bdd with Cucumber and MochaBdd with Cucumber and Mocha
Bdd with Cucumber and Mocha
Atish Narlawar
 
Insights on Protractor testing
Insights on Protractor testingInsights on Protractor testing
Insights on Protractor testing
Dejan Toteff
 
Fabulous Tests on Spock and Groovy
Fabulous Tests on Spock and GroovyFabulous Tests on Spock and Groovy
Fabulous Tests on Spock and Groovy
Yaroslav Pernerovsky
 
Brace yourself from automation death trap
Brace yourself from automation death trapBrace yourself from automation death trap
Brace yourself from automation death trap
Prasad Kalgutkar
 
Test Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEMTest Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEM
Sagar Sane
 
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR Meetup
 
Behaviour driven development aka bdd
Behaviour driven development aka bddBehaviour driven development aka bdd
Behaviour driven development aka bdd
Prince Gupta
 

Similar to Intro to Service Worker API and its use cases (20)

Azure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCCAzure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCC
Baskar rao Dsn
 
Advanced Web Technology.pptx
Advanced Web Technology.pptxAdvanced Web Technology.pptx
Advanced Web Technology.pptx
ssuser35fdf2
 
Era of server less computing final
Era of server less computing finalEra of server less computing final
Era of server less computing final
Baskar rao Dsn
 
Era of server less computing
Era of server less computingEra of server less computing
Era of server less computing
Baskar rao Dsn
 
Web optimization with service woker
Web optimization with service wokerWeb optimization with service woker
Web optimization with service woker
Chen-Tien Tsai
 
Caching strategies with lucee
Caching strategies with luceeCaching strategies with lucee
Caching strategies with lucee
Gert Franz
 
Play with azure functions
Play with azure functionsPlay with azure functions
Play with azure functions
Baskar rao Dsn
 
Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15
Derek Ashmore
 
Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!
Jeremy Likness
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
Yochay Kiriaty
 
Stay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolithStay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolith
Markus Eisele
 
Serverless Architectures
Serverless Architectures Serverless Architectures
Serverless Architectures
SuraiyaHasan19004210
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterprise
Taylor Lovett
 
Picnic Software - Developing a flexible and scalable application
Picnic Software - Developing a flexible and scalable applicationPicnic Software - Developing a flexible and scalable application
Picnic Software - Developing a flexible and scalable application
Nick Josevski
 
What is Serverless Computing?
What is Serverless Computing?What is Serverless Computing?
What is Serverless Computing?
AIMDek Technologies
 
Service workers are your best friends
Service workers are your best friendsService workers are your best friends
Service workers are your best friends
Antonio Peric-Mazar
 
Progressive Web App
Progressive Web AppProgressive Web App
Progressive Web App
SaleemMalik52
 
Serverless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From ProductionServerless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From Production
Steve Hogg
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in Enterprise
Taylor Lovett
 
Grails Services
Grails ServicesGrails Services
Grails Services
NexThoughts Technologies
 
Azure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCCAzure Functions in Action #OrlandoCC
Azure Functions in Action #OrlandoCC
Baskar rao Dsn
 
Advanced Web Technology.pptx
Advanced Web Technology.pptxAdvanced Web Technology.pptx
Advanced Web Technology.pptx
ssuser35fdf2
 
Era of server less computing final
Era of server less computing finalEra of server less computing final
Era of server less computing final
Baskar rao Dsn
 
Era of server less computing
Era of server less computingEra of server less computing
Era of server less computing
Baskar rao Dsn
 
Web optimization with service woker
Web optimization with service wokerWeb optimization with service woker
Web optimization with service woker
Chen-Tien Tsai
 
Caching strategies with lucee
Caching strategies with luceeCaching strategies with lucee
Caching strategies with lucee
Gert Franz
 
Play with azure functions
Play with azure functionsPlay with azure functions
Play with azure functions
Baskar rao Dsn
 
Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15
Derek Ashmore
 
Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!
Jeremy Likness
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
Yochay Kiriaty
 
Stay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolithStay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolith
Markus Eisele
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterprise
Taylor Lovett
 
Picnic Software - Developing a flexible and scalable application
Picnic Software - Developing a flexible and scalable applicationPicnic Software - Developing a flexible and scalable application
Picnic Software - Developing a flexible and scalable application
Nick Josevski
 
Service workers are your best friends
Service workers are your best friendsService workers are your best friends
Service workers are your best friends
Antonio Peric-Mazar
 
Serverless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From ProductionServerless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From Production
Steve Hogg
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in Enterprise
Taylor Lovett
 
Ad

Recently uploaded (20)

FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Ad

Intro to Service Worker API and its use cases

  • 1. Intro to Service Worker API and its use cases Satej Kumar Sahu Mindfire Solutions
  • 2. Contents • What is a Service Worker? • Service Worker concepts • Promise concept • Some general pointers • Service Worker example • Debugging tips • Service Worker Support • Service Worker use cases • Conclusion
  • 3. What is a Service Worker? • At it’s simplest it’s a worker. • A worker is a JavaScript script that runs in the background, independently of other scripts in a separate thread, without affecting the performance of the page. • A service worker is run in a worker context: it therefore has no DOM access, and runs on a different thread to the main JavaScript that powers your app, so it is not blocking. It is designed to be fully async; as a consequence, APIs such as synchronous XHR and localStorage can't be used inside a service worker.
  • 4. Service Worker Concepts • Worker • Promise • Registration • Install • Activate
  • 6. Promise concept • Promises are a great mechanism for running async operations • sync try { var value = myFunction(); console.log(value); } catch(err) { console.log(err); } • async myFunction().then(function(value) { console.log(value); }).catch(function(err) { console.log(err); });
  • 7. • There have been various attempts to create technologies to solve this problem • There still isn’t a good overall control mechanism for asset caching and custom network requests. • AppCache — seemed to be a good idea because it allowed you to specify assets to cache really easily. But it relied on many assumptions and when you didn’t follow them, it breaks.
  • 8. Some general pointers • As of Firefox 44, when AppCache is used to provide offline support for a page a warning message is now displayed in the console advising developers to use Service workers instead. • Offline first experience. Native Apps already provide them so they are much favoured. • Many service workers features are now enabled by default in newer versions of supporting browsers. • If still not working, then please try - Firefox Nightly: about:config -> dom.serviceWorkers.enabled to true -> restart - Chrome Canary: chrome://flags -> turn on experimental-web-platform-features -> restart - Opera: opera://flags -> enable Support for ServiceWorker -> restart • Service Workers are restricted to running across HTTPS for security reasons.
  • 9. Service Worker example • Service Worker presence. If not present then fallback to other ways AppCache, indexed DB etc. else load from network. • Basic Architecture • Registering a Service Worker • Install and Activation process • Cache control and custom responses
  • 12. Debugging tips • Chrome has chrome://inspect/#service-workers, which shows current service worker activity and storage on a device • chrome://serviceworker-internals, which shows more detail and allows you to start/stop/debug the worker process • In the future they will have throttling/offline modes to simulate bad or non-existent connections, which will be a really good thing. • Firefox: You can navigate to about:serviceworkers to see what SWs are registered and update/remove them. • When testing you can get around the HTTPS restriction by checking the "Enable Service Workers over HTTP (when toolbox is open)" option in the Firefox Devtools options (gear menu.)
  • 13. Service Worker Support • https://jakearchibald.github.io/isserviceworkerready/ • caniuse.com/#feat=serviceworkers
  • 14. Service Worker use cases • Caching • Loss of connectivity. Offline user experience • Background data synchronization • Responding to resource requests from other origins • Receiving centralized updates to expensive-to-calculate data such as geolocation or gyroscope, so multiple pages can make use of one set of data • Client-side compiling and dependency management of CoffeeScript, less, CJS/AMD modules, etc. for dev purposes • Hooks for background services • Custom templating based on certain URL patterns • Performance enhancements, for example pre-fetching resources that the user is likely to need in the near future, such as the next few pictures in a photo album.
  • 16. Conclusion • Offline first experience for a better user experience • Caching and data bandwidth usage reduction.
  • 18. Any?