SlideShare a Scribd company logo
1 of 17
Download to read offline
S E R V I C E
W O R K E R S
w i t h S a l l y a n d L a r r y
Hi Larry! Let's learn a little
about service workers
today.
Service
Workers...
Do they do
something with
building apps?
That means we can access the app
when we don't have signal?
Exactly! Service workers make
working offline possible.
Yes!
It's a JavaScript file? Does
that mean it works with the
DOM?
Service Workers are just
another JavaScript file
that we create.
No - and that's what
makes it work offline.
Really? How does the service worker
work with the browser?
Even though service workers
don't have access to the DOM it
does have access to the browser
capabilities
I'm glad you asked - it's really
interesting!
Yes, that's right.
When you go to a website you either
type it in or click on a link, right?
Okay, after you type or click on the
URL your computer uses the cables
and satellites to contact the web
server that's hosting your website.
The information you're looking for
is then sent to you on those cables
and satellites from the web server.
Search for
www.hocking.edu
Sees the homepage for www.hocking.edu
For example, if Susie is looking to check
out Hocking College she can do a search
online and click on the link for
www.hocking.edu. Susie's computer uses
cables, radio towers and satellites to find
the server where the Hocking College
website is hosted. The server sends her the
files (the web pages) she's asked for.
If a Service Worker file is included,
Susie's search goes to the Service Worker
first.
Search for
www.hocking.edu
Sees the homepage for www.hocking.edu
Well, the service worker leaves
instructions to the browser that
Susie is using. Those instructions
will be performed before the
request is sent further.
Do you see how Susie's request went
to a service worker instead of going
straight to the radio towers, cables
and satellites?
Yes, what does it do there?
Yes! That's why these service
worker pages don't access the DOM.
If no other pages are loaded yet,
there's nothing for it to look
through.
For example, the service worker can
tell the browser "If the user is asking
for a particular URL, run this
JavaScript file (the service worker
file) first."
So the browser runs that file first before
any of the other pages are searched for
or loaded?
There are three different analogies we can use
to help better understand. Let's go over
them.
Cookie Virus Toolbox
Cookies and Service
Workers are downloaded
when accessing a
website
Service Workers are
more powerful than
cookies as they contain
a set of instructions.
Those instructions are
reviewed before making
a requests to the
website that originally
installed the service
worker.
Viruses and Service
Workers are installed
in the background
when first visit a
website.
Afterwards when a
request to the website
is made, the service
worker intercepts it.
The service worker
can only handle
requests for the
original website that
installed the service
worker.
Tools and Service
Workers don't do
much on their own
but they are useful
when needing to
access something.
Service workers
allow access to
powerful browser
features
Instructions can be
written in service
workers to take
advantage of the
tools
Yes! You got it!
You can see that all three
analogies help with the
understanding of what a service
worker does.
Yes, so basically the service worker
JavaScript file is downloaded onto
our computer when we first visit a
website. The next time we visit our
browser reads those instructions first.
Does that sound right?
So you can see that service
workers can be very powerful.
But you know what they say
"With great power, comes great
responsibility".
Yeah, I think I've heard that before.
Think about it. If there was a
hacker who wanted to create
havoc all they would have to do is
impersonate a website and write
their own service worker with evil
instructions. So there are some
policies that need to be followed.
It's important to be sure that the
service worker really belongs to the
site it claims it's from. For example if
a service worker says its for
www.example.com - it really is from
www.example.com
Okay, I think I know what you mean. Can
you explain a bit more?
Certainly! Sometimes webpages use
third party providers to hold images
and other assets. That works fine for
those instances. The service workers
HAVE to be part of the original
website. It can't be hosted elsewhere.
The same origin is one policy that
service workers have to follow.
Okay, what is the other one?
Service workers can only be used on
HTTPS websites. If a website is only
HTTP and doesn't have the S
(indicates it's secured), the service
worker won't work.
When publishing your website for
others to see you need to be sure your
site is secured with HTTPS, but you
don't need to do that while your still
building your app.
That's good! I wasn't sure how that was
going to work when we're still in testing
phase. How else can we see our site with
the service worker in action?
You can build and test with the
service worker while working with
your local host (web server on your
own computer).
Hopefully this helps explain what a
Service Worker is and how it help
build apps for users to use - even if
they aren't online or connected.
If you have questions please feel free
to reach out to Tasha Penwell at
Hocking College at the information
below.
Text: 740-300-1684
Email: penwellt31810@hocking.edu
Source: https://abookapart.com/

More Related Content

Similar to Service Workers and Their Role in Apps

Shaping up with angular JS
Shaping up with angular JSShaping up with angular JS
Shaping up with angular JSBrajesh Yadav
 
Get Top
Get Top Get Top
Get Top auto446
 
Introduction to web design
Introduction to web designIntroduction to web design
Introduction to web designFitra Sani
 
Web Server Application Logs LTEC2013
Web Server Application Logs LTEC2013Web Server Application Logs LTEC2013
Web Server Application Logs LTEC2013Michal Špaček
 
2020 Top Web Development Trends
2020 Top Web Development Trends2020 Top Web Development Trends
2020 Top Web Development TrendsPencil Agency
 
Challenges in web crawling
Challenges in web crawlingChallenges in web crawling
Challenges in web crawlingBurhan Ahmed
 
Semantic Web: Explanation
Semantic Web: ExplanationSemantic Web: Explanation
Semantic Web: ExplanationAnil Mishra
 
The semantic web
The semantic webThe semantic web
The semantic webDotkumo
 
How developer's can help seo
How developer's can help seo How developer's can help seo
How developer's can help seo Gunjan Srivastava
 
A Beginner's Guide To Web Design
A Beginner's Guide To Web DesignA Beginner's Guide To Web Design
A Beginner's Guide To Web DesignAis Technolabs
 
Linking: Viral Advertising is a Good Virus
Linking: Viral Advertising is a Good VirusLinking: Viral Advertising is a Good Virus
Linking: Viral Advertising is a Good Virusmtwdhs0001
 
Basic SEO Structural Issues
Basic SEO Structural IssuesBasic SEO Structural Issues
Basic SEO Structural IssuesR2integrated
 
Ijaprr vol1-5-24-29mukesh negi
Ijaprr vol1-5-24-29mukesh negiIjaprr vol1-5-24-29mukesh negi
Ijaprr vol1-5-24-29mukesh negiijaprr_editor
 
Designing with content-first
Designing with content-firstDesigning with content-first
Designing with content-firstAndy Parker
 
This is the web platform
This is the web platformThis is the web platform
This is the web platformPaul Kinlan
 
Jmp206 Web Services Bootcamp Final Draft
Jmp206   Web Services Bootcamp Final DraftJmp206   Web Services Bootcamp Final Draft
Jmp206 Web Services Bootcamp Final DraftBill Buchan
 
Search Engine Optimization-tips & tricks
Search Engine Optimization-tips & tricksSearch Engine Optimization-tips & tricks
Search Engine Optimization-tips & tricksdigisays
 
Search engine optimization_strategies_-_part_2
Search engine optimization_strategies_-_part_2Search engine optimization_strategies_-_part_2
Search engine optimization_strategies_-_part_2Flora Runyenje
 

Similar to Service Workers and Their Role in Apps (20)

Shaping up with angular JS
Shaping up with angular JSShaping up with angular JS
Shaping up with angular JS
 
Get Top
Get Top Get Top
Get Top
 
Introduction to web design
Introduction to web designIntroduction to web design
Introduction to web design
 
Web Server Application Logs LTEC2013
Web Server Application Logs LTEC2013Web Server Application Logs LTEC2013
Web Server Application Logs LTEC2013
 
2020 Top Web Development Trends
2020 Top Web Development Trends2020 Top Web Development Trends
2020 Top Web Development Trends
 
Challenges in web crawling
Challenges in web crawlingChallenges in web crawling
Challenges in web crawling
 
Semantic Web: Explanation
Semantic Web: ExplanationSemantic Web: Explanation
Semantic Web: Explanation
 
The semantic web
The semantic webThe semantic web
The semantic web
 
How developer's can help seo
How developer's can help seo How developer's can help seo
How developer's can help seo
 
A Beginner's Guide To Web Design
A Beginner's Guide To Web DesignA Beginner's Guide To Web Design
A Beginner's Guide To Web Design
 
Linking: Viral Advertising is a Good Virus
Linking: Viral Advertising is a Good VirusLinking: Viral Advertising is a Good Virus
Linking: Viral Advertising is a Good Virus
 
Basic SEO Structural Issues
Basic SEO Structural IssuesBasic SEO Structural Issues
Basic SEO Structural Issues
 
Article20
Article20Article20
Article20
 
Ijaprr vol1-5-24-29mukesh negi
Ijaprr vol1-5-24-29mukesh negiIjaprr vol1-5-24-29mukesh negi
Ijaprr vol1-5-24-29mukesh negi
 
Designing with content-first
Designing with content-firstDesigning with content-first
Designing with content-first
 
Domain Name
Domain NameDomain Name
Domain Name
 
This is the web platform
This is the web platformThis is the web platform
This is the web platform
 
Jmp206 Web Services Bootcamp Final Draft
Jmp206   Web Services Bootcamp Final DraftJmp206   Web Services Bootcamp Final Draft
Jmp206 Web Services Bootcamp Final Draft
 
Search Engine Optimization-tips & tricks
Search Engine Optimization-tips & tricksSearch Engine Optimization-tips & tricks
Search Engine Optimization-tips & tricks
 
Search engine optimization_strategies_-_part_2
Search engine optimization_strategies_-_part_2Search engine optimization_strategies_-_part_2
Search engine optimization_strategies_-_part_2
 

More from Tasha Penwell

The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptxThe Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptxTasha Penwell
 
Revolutionize the way you work with AI and ChatGPT..gslides (2).pdf
Revolutionize the way you work with AI and ChatGPT..gslides (2).pdfRevolutionize the way you work with AI and ChatGPT..gslides (2).pdf
Revolutionize the way you work with AI and ChatGPT..gslides (2).pdfTasha Penwell
 
4 Ways That Snapchat Can Be Used in the Classroom.pdf
4 Ways That Snapchat Can Be Used in the Classroom.pdf4 Ways That Snapchat Can Be Used in the Classroom.pdf
4 Ways That Snapchat Can Be Used in the Classroom.pdfTasha Penwell
 
Snap Into It Bring Snapchat to the Classroom 20230124.pdf
Snap Into It Bring Snapchat to the Classroom 20230124.pdfSnap Into It Bring Snapchat to the Classroom 20230124.pdf
Snap Into It Bring Snapchat to the Classroom 20230124.pdfTasha Penwell
 
Roles in Cloud Computing
Roles in Cloud ComputingRoles in Cloud Computing
Roles in Cloud ComputingTasha Penwell
 
Snapchat Insights from Community Lens Filter Experience
Snapchat Insights from Community Lens Filter ExperienceSnapchat Insights from Community Lens Filter Experience
Snapchat Insights from Community Lens Filter ExperienceTasha Penwell
 
AWS Shared Responsibility Model
AWS Shared Responsibility ModelAWS Shared Responsibility Model
AWS Shared Responsibility ModelTasha Penwell
 
Fetch with Frankie and Bowser
Fetch with Frankie and BowserFetch with Frankie and Bowser
Fetch with Frankie and BowserTasha Penwell
 
Let's learn about Lex and IAM Roles
Let's learn about Lex and IAM RolesLet's learn about Lex and IAM Roles
Let's learn about Lex and IAM RolesTasha Penwell
 
Tasha Penwell Resume.docx
Tasha Penwell Resume.docxTasha Penwell Resume.docx
Tasha Penwell Resume.docxTasha Penwell
 

More from Tasha Penwell (12)

The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptxThe Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
 
Revolutionize the way you work with AI and ChatGPT..gslides (2).pdf
Revolutionize the way you work with AI and ChatGPT..gslides (2).pdfRevolutionize the way you work with AI and ChatGPT..gslides (2).pdf
Revolutionize the way you work with AI and ChatGPT..gslides (2).pdf
 
4 Ways That Snapchat Can Be Used in the Classroom.pdf
4 Ways That Snapchat Can Be Used in the Classroom.pdf4 Ways That Snapchat Can Be Used in the Classroom.pdf
4 Ways That Snapchat Can Be Used in the Classroom.pdf
 
Snap Into It Bring Snapchat to the Classroom 20230124.pdf
Snap Into It Bring Snapchat to the Classroom 20230124.pdfSnap Into It Bring Snapchat to the Classroom 20230124.pdf
Snap Into It Bring Snapchat to the Classroom 20230124.pdf
 
Roles in Cloud Computing
Roles in Cloud ComputingRoles in Cloud Computing
Roles in Cloud Computing
 
Snapchat Insights from Community Lens Filter Experience
Snapchat Insights from Community Lens Filter ExperienceSnapchat Insights from Community Lens Filter Experience
Snapchat Insights from Community Lens Filter Experience
 
Amazon Career Day
Amazon Career DayAmazon Career Day
Amazon Career Day
 
AWS Shared Responsibility Model
AWS Shared Responsibility ModelAWS Shared Responsibility Model
AWS Shared Responsibility Model
 
Fetch with Frankie and Bowser
Fetch with Frankie and BowserFetch with Frankie and Bowser
Fetch with Frankie and Bowser
 
Let's learn about Lex and IAM Roles
Let's learn about Lex and IAM RolesLet's learn about Lex and IAM Roles
Let's learn about Lex and IAM Roles
 
A Bot Named Lex
A Bot Named LexA Bot Named Lex
A Bot Named Lex
 
Tasha Penwell Resume.docx
Tasha Penwell Resume.docxTasha Penwell Resume.docx
Tasha Penwell Resume.docx
 

Recently uploaded

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Service Workers and Their Role in Apps

  • 1. S E R V I C E W O R K E R S w i t h S a l l y a n d L a r r y
  • 2. Hi Larry! Let's learn a little about service workers today. Service Workers... Do they do something with building apps?
  • 3. That means we can access the app when we don't have signal? Exactly! Service workers make working offline possible. Yes!
  • 4. It's a JavaScript file? Does that mean it works with the DOM? Service Workers are just another JavaScript file that we create. No - and that's what makes it work offline.
  • 5. Really? How does the service worker work with the browser? Even though service workers don't have access to the DOM it does have access to the browser capabilities I'm glad you asked - it's really interesting!
  • 6. Yes, that's right. When you go to a website you either type it in or click on a link, right? Okay, after you type or click on the URL your computer uses the cables and satellites to contact the web server that's hosting your website. The information you're looking for is then sent to you on those cables and satellites from the web server.
  • 7. Search for www.hocking.edu Sees the homepage for www.hocking.edu For example, if Susie is looking to check out Hocking College she can do a search online and click on the link for www.hocking.edu. Susie's computer uses cables, radio towers and satellites to find the server where the Hocking College website is hosted. The server sends her the files (the web pages) she's asked for.
  • 8. If a Service Worker file is included, Susie's search goes to the Service Worker first. Search for www.hocking.edu Sees the homepage for www.hocking.edu
  • 9. Well, the service worker leaves instructions to the browser that Susie is using. Those instructions will be performed before the request is sent further. Do you see how Susie's request went to a service worker instead of going straight to the radio towers, cables and satellites? Yes, what does it do there?
  • 10. Yes! That's why these service worker pages don't access the DOM. If no other pages are loaded yet, there's nothing for it to look through. For example, the service worker can tell the browser "If the user is asking for a particular URL, run this JavaScript file (the service worker file) first." So the browser runs that file first before any of the other pages are searched for or loaded?
  • 11. There are three different analogies we can use to help better understand. Let's go over them. Cookie Virus Toolbox Cookies and Service Workers are downloaded when accessing a website Service Workers are more powerful than cookies as they contain a set of instructions. Those instructions are reviewed before making a requests to the website that originally installed the service worker. Viruses and Service Workers are installed in the background when first visit a website. Afterwards when a request to the website is made, the service worker intercepts it. The service worker can only handle requests for the original website that installed the service worker. Tools and Service Workers don't do much on their own but they are useful when needing to access something. Service workers allow access to powerful browser features Instructions can be written in service workers to take advantage of the tools
  • 12. Yes! You got it! You can see that all three analogies help with the understanding of what a service worker does. Yes, so basically the service worker JavaScript file is downloaded onto our computer when we first visit a website. The next time we visit our browser reads those instructions first. Does that sound right?
  • 13. So you can see that service workers can be very powerful. But you know what they say "With great power, comes great responsibility". Yeah, I think I've heard that before. Think about it. If there was a hacker who wanted to create havoc all they would have to do is impersonate a website and write their own service worker with evil instructions. So there are some policies that need to be followed.
  • 14. It's important to be sure that the service worker really belongs to the site it claims it's from. For example if a service worker says its for www.example.com - it really is from www.example.com Okay, I think I know what you mean. Can you explain a bit more? Certainly! Sometimes webpages use third party providers to hold images and other assets. That works fine for those instances. The service workers HAVE to be part of the original website. It can't be hosted elsewhere.
  • 15. The same origin is one policy that service workers have to follow. Okay, what is the other one? Service workers can only be used on HTTPS websites. If a website is only HTTP and doesn't have the S (indicates it's secured), the service worker won't work.
  • 16. When publishing your website for others to see you need to be sure your site is secured with HTTPS, but you don't need to do that while your still building your app. That's good! I wasn't sure how that was going to work when we're still in testing phase. How else can we see our site with the service worker in action? You can build and test with the service worker while working with your local host (web server on your own computer).
  • 17. Hopefully this helps explain what a Service Worker is and how it help build apps for users to use - even if they aren't online or connected. If you have questions please feel free to reach out to Tasha Penwell at Hocking College at the information below. Text: 740-300-1684 Email: penwellt31810@hocking.edu Source: https://abookapart.com/