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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Joselito
January 13, 2016
Programming
230
2
Share
WebApps Offline com ServiceWorkers
Hangout - GDG BH
Joselito
January 13, 2016
More Decks by Joselito
See All by Joselito
Apresentando window.ai
joselito
0
76
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
95
Eleventy: Sites em 3 minutos ou seu dinheiro de volta
joselito
0
66
Dando rollback no site do governo
joselito
0
270
Chrome Dev Summit'18
joselito
0
89
Next.js: o desenvolvedor feliz de novo
joselito
0
180
Componentizando a Web
joselito
0
180
Firebase para se divertir com IoT
joselito
0
170
Other Decks in Programming
See All in Programming
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
460
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
1.2k
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
270
ビジネスモデルから紐解く、AI+型駆動開発
hirokiomote
2
5.2k
さぁV100、メモリをお食べ・・・
nilpe
0
130
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.1k
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
3.5k
OSもどきOS
arkw
0
400
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
2.5k
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.5k
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
160
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
180
Featured
See All Featured
Crafting Experiences
bethany
1
160
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
190
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
71
40k
Facilitating Awesome Meetings
lara
57
6.9k
Writing Fast Ruby
sferik
630
63k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
440
How STYLIGHT went responsive
nonsquared
100
6.2k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
150
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
160
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
200
The agentic SEO stack - context over prompts
schlessera
0
790
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