Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
WebApps Offline com ServiceWorkers
Search
Joselito
January 13, 2016
Programming
2
220
WebApps Offline com ServiceWorkers
Hangout - GDG BH
Joselito
January 13, 2016
Tweet
Share
More Decks by Joselito
See All by Joselito
Apresentando window.ai
joselito
0
53
Virei Lead, como me manter Tech enquanto gerencio pessoas?
joselito
0
150
Você (provavelmente) não sabia que o Chrome DevTools tinha isso
joselito
1
88
Eleventy: Sites em 3 minutos ou seu dinheiro de volta
joselito
0
55
Dando rollback no site do governo
joselito
0
260
Chrome Dev Summit'18
joselito
0
84
Next.js: o desenvolvedor feliz de novo
joselito
0
170
Componentizando a Web
joselito
0
170
Firebase para se divertir com IoT
joselito
0
160
Other Decks in Programming
See All in Programming
Rails Girls Tokyo 18th GMO Pepabo Sponsor Talk
yutokyokutyo
0
190
株式会社 Sun terras カンパニーデック
sunterras
0
2k
Claude Code の Skill で複雑な既存仕様をすっきり整理しよう
yuichirokato
1
280
CDIの誤解しがちな仕様とその対処TIPS
futokiyo
0
160
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
1.6k
米国のサイバーセキュリティタイムラインと見る Goの暗号パッケージの進化
tomtwinkle
2
420
Head of Engineeringが現場で回した生産性向上施策 2025→2026
gessy0129
0
210
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
190
nuget-server - あなたが必要だったNuGetサーバー
kekyo
PRO
0
160
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
0
160
PJのドキュメントを全部Git管理にしたら、一番喜んだのはAIだった
nanaism
0
230
「やめとこ」がなくなった — 1月にZennを始めて22本書いた AI共創開発のリアル
atani14
0
350
Featured
See All Featured
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
150
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
110
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
490
Being A Developer After 40
akosma
91
590k
Paper Plane (Part 1)
katiecoart
PRO
0
5.1k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
260
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
My Coaching Mixtape
mlcsv
0
63
SEO for Brand Visibility & Recognition
aleyda
0
4.3k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
170
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.1k
Transcript
JOSELITO.NINJA WEB APPS OFFLINE Hangout - GDG Belo Horizonte
@joselitojunior1
MOBILE @joselitojunior1
NATIVO v WEB @joselitojunior1
NATIVO v WEB @joselitojunior1
@joselitojunior1
@joselitojunior1 PROGRESIVE APPS
@joselitojunior1 PROGRESIVE APPS offline first responsive fresh content https safe
indexable installable linkable engageble
@joselitojunior1 PROGRESIVE APPS offline first responsive fresh content https safe
indexable installable linkable engageble
Olá, Joselito • Modelo e atriz • Instrutor, palestrante •
Ex-BBB • GDG Organizer • Fã de F1 • Resolvedor® de problemas • #chrominho
@joselitojunior1 OFFLINE APPS
@joselitojunior1 hIps://speakerdeck.com/joselitojunior1
@joselitojunior1 OFFLINE === USER EXPERIENCE
SERVICE WORKERS @joselitojunior1
@joselitojunior1
SERVICE WORKERS @joselitojunior1 Registro do SW no navegador
@joselitojunior1 if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/ssw.js', { scope: '/'
}).then(function(reg) { // Service Worker registrado! }).catch(function(error) { // Não foi possível registrar o Service Worker console.log(error); }); };
@joselitojunior1 this.addEventListener('install', function(event) { event.waitUntil( caches.open('cache-versao-1').then(function(cache) { return cache.addAll([ '/public/',
'/public/index.html', '/public/estilo.css', '/public/app.js', '/public/image-list.js', '/public/info.json' ]); }) ); });
@joselitojunior1 this.addEventListener('fetch', function(event) { event.respondWith( // Mágica! ); });
@joselitojunior1 this.addEventListener('fetch', function(event) { event.respondWith( // Response() ); });
SERVICE WORKERS @joselitojunior1 Response()
@joselitojunior1 new Response('Hello from GDG Humildão');
@joselitojunior1 new Response('<p>Hello from GDG Humildão!</p>', { headers: { 'Content-Type':
'text/html' } })
@joselitojunior1 fetch(event.request)
@joselitojunior1 caches.match('/fallback.html');
@joselitojunior1 caches.match('/fallback.html');
SERVICE WORKERS @joselitojunior1 onfetch()
@joselitojunior1 self.addEventListener('fetch', function(event) { event.respondWith( caches.match(event.request).then(function(response) { return response ||
fetch(event.request); }) ); });
@joselitojunior1 self.addEventListener('fetch', function(event) { event.respondWith( caches.open('mysite-dynamic').then(function(cache) { return cache.match(event.request).then(function (response)
{ return response || fetch(event.request).then(function(response) { cache.put(event.request, response.clone()); return response; }); }); }) ); });
@joselitojunior1 self.addEventListener('fetch', function(event) { event.respondWith( caches.open('mysite-dynamic').then(function(cache) { return cache.match(event.request).then(function(response) {
var fetchPromise = fetch(event.request).then(function(networkResponse) { cache.put(event.request, networkResponse.clone()); return networkResponse; }) return response || fetchPromise; }) }) ); });
SERVICE WORKERS @joselitojunior1 onsync()
@joselitojunior1 self.addEventListener('sync', function(event) { if (event.id == 'update-leaderboard') { event.waitUntil(
caches.open('mygame-dynamic').then(function(cache) { return cache.add('/leaderboard.json'); }) ); } });
SERVICE WORKERS @joselitojunior1 onactivate()
@joselitojunior1 self.addEventListener('activate', function(event) { // Service Worker funcionando! });
@joselitojunior1 self.onactivate = function(event) { event.waitUntil( caches.keys().then(function(cacheNames) { return Promise.all(
cacheNames.map(function(cacheName) { if (expectedCaches.indexOf(cacheName) == -1) { return caches.delete(cacheName); } }) ); }) ); };
SERVICE WORKERS @joselitojunior1 Debugando
@joselitojunior1
SERVICE WORKERS @joselitojunior1 Exemplos
@joselitojunior1 Wikipedia OTine github.com/jakearchibald/oTine-wikipedia
@joselitojunior1 DevFest Nordeste github.com/devfestne/2015-site
Obrigado (: JOSELITO.NINJA @joselitojunior1