SlideShare a Scribd company logo
Stanco delle solite
web app? Passa al
Progressive!
Federico “Edo” Granata
By
Hello World!
Io sono Federico “Edo” Granata
Potete trovarmi su
https://federicogranata.dev
1
Progressive Web App
Non facciamoci
intimorire
Le caratteristiche di una PWA
Veloce
Secondo un
sorprendente
sondaggio gli
utenti non
apprezzano le app
lente.
Affidabile
L’utente deve
poter interagire
a prescindere
dalle condizioni
di rete.
Accattivante
Una PWA è
installabile,
offre
un’esperienza
full-screen e
consente di usare
push
notifications.
... ma in pratica?
HTTPS
Tutto il traffico
DEVE essere
cifrato.
Manifest
Un semplice file
per indicare al
browser che ha a
che fare con una
PWA.
Service Worker
Un JS in cui
avviene la magia
che consente di
gestire cache e
notifiche push.
<link rel="manifest" href="/manifest.json">
{
"short_name": "Maps",
"name": "Google Maps",
"icons": [
{
"src": "/images/icons-192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "/images/icons-512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "/pwa/?source=pwa",
"scope": "/pwa/",
"display": "standalone",
"background_color": "#123456",
"theme_color": "#FEDCBA"
}
Manifest.json
Service Worker
▪ JavaScript
▪ Separato dalla pagina
▪ Background
▪ Event Driven
▪ Magia
... magia?
PRO
▪ Programmable Proxy
▪ Background Sync
▪ Push Notifications
CONTRO
▪ DOM
▪ Nessuna persistenza
Programmable Proxy
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request)
.then(function(response) {
// Cache hit - return response
if (response) {
return response;
}
return fetch(event.request);
}
)
);
});
Service Worker LifeCycle
▪ .register()
▪ Evento install
▪ Una promise viene passata a
installEvent.waitUntil()
▪ Un service worker non riceve eventi e
push fino a quando diventa "active".
▪ Le richieste di una pagina non passano da
un service worker a meno che la pagina
stessa sia passata da un service worker
▪ clients.claim() può prendere il controllo
immediatamente
<!DOCTYPE html>
An image will appear here in 3 seconds:
<script>
navigator.serviceWorker.register('/sw.js')
.then(reg => console.log('SW registered!', reg))
.catch(err => console.log('Boo!', err));
setTimeout(() => {
const img = new Image();
img.src = '/dog.svg';
document.body.appendChild(img);
}, 3000);
</script>
self.addEventListener('install', event => {
event.waitUntil(
caches.open('static-v1').then(fuction(cache) {
cache.add('/cat.svg');
});
);
});
self.addEventListener('activate', event => {
console.log('ready');
});
self.addEventListener('fetch', event => {
const url = new URL(event.request.url);
if (url.origin == location.origin &&
url.pathname == '/dog.svg') {
event.respondWith(caches.match('/cat.svg'));
}
});
DEMO 1 DEMO 2
Service Worker Update
▪ Download nuovo SW
▪ Eseguito in parallelo (riceve il
suo evento install)
▪ Attende che la precedente
versione non sia più in uso
▪ Oppure self.skipWaiting()
Made Easy
Workbox is a library that bakes in
a set of best practices and removes
the boilerplate every developer
writes when working with service
workers.
Workbox
▪ Precaching
▪ Runtime caching
▪ Strategies
▪ Request routing
▪ Background sync
▪ Helpful debugging
▪ Greater flexibility and feature
set than sw-precache and
sw-toolbox
Workbox Programmable Proxy - Basic
workbox.routing.registerRoute(
/.(?:js|css)$/,
new workbox.strategies.StaleWhileRevalidate(),
);
Workbox Programmable Proxy - Intermediate
workbox.routing.registerRoute(
/.(?:png|gif|jpg|jpeg|svg)$/,
new workbox.strategies.CacheFirst({
cacheName: 'images',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 60,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days
}),
],
}),
);
Workbox Programmable Proxy - Advanced
workbox.routing.registerRoute(
/^https://fonts.gstatic.com/,
new workbox.strategies.CacheFirst({
cacheName: 'google-fonts-webfonts',
plugins: [
new workbox.cacheableResponse.Plugin({
statuses: [0, 200],
}),
new workbox.expiration.Plugin({
maxAgeSeconds: 60 * 60 * 24 * 365,
}),
],
}),
);
Workbox Background Sync
const bgSyncPlugin = new
workbox.backgroundSync.Plugin('myQueueName', {
maxRetentionTime: 24 * 60 // Retry for max of 24 Hours
});
workbox.routing.registerRoute(
//api/.*/*.json/,
new workbox.strategies.NetworkOnly({
plugins: [bgSyncPlugin]
}),
'POST'
);
Workbox offre molto altro
▪ 13 moduli Service Worker
▪ 1 modulo Window
▪ Tools per automatizzare (cli,
npm, gulp, grunt e webpack)
Risorse Utili
▪ Manifest - http://bit.ly/313G047
▪ Install - http://bit.ly/311fYOZ
▪ Service Worker - http://bit.ly/2KqBU03
▪ SW LyfeCycle - http://bit.ly/30Hjuxb
▪ Workbox - http://bit.ly/311EAr5
▪ PWA Starter Kit - http://bit.ly/2JU1Wau
▪ Bento Starter - http://bit.ly/2JC4ZVI
▪ PWA Checklist - http://bit.ly/313GtTV
Thanks!
ANY QUESTIONS?
You can find me at:
federico.granata@gmail.com
https://federicogranata.dev
http://bit.ly/Edo-LinkedIn
CREDITS
Special thanks to all the people who made and released
these awesome resources for free:
▪ Presentation template by SlidesCarnival

More Related Content

What's hot (11)

PPTX
Workflow Dev-Test-Live per WordPress
Farnedi ICT srl
 
PDF
Task automation with grunt
lucatume
 
PDF
Cloud DB, il Database as a Service di Seeweb
seeweb
 
PDF
Gae piattaforma su cloud
masci
 
PPT
node.js e Postgresql
Lucio Grenzi
 
PPTX
Dal requisito all'implementazione @ CD2010
Mauro Servienti
 
PPTX
Java EE facile con Spring Boot - Luigi Bennardis - Codemotion Roma 2015
Codemotion
 
PDF
Madaudo
yithemes
 
PPT
SUE AGILE Architettura (Italiano)
Sabino Labarile
 
PDF
SLA Confidential
VMUG IT
 
PDF
Ignite IBB: Gabriele Loiacono - qube-os un sistema operativo web based per sv...
Toscanalab
 
Workflow Dev-Test-Live per WordPress
Farnedi ICT srl
 
Task automation with grunt
lucatume
 
Cloud DB, il Database as a Service di Seeweb
seeweb
 
Gae piattaforma su cloud
masci
 
node.js e Postgresql
Lucio Grenzi
 
Dal requisito all'implementazione @ CD2010
Mauro Servienti
 
Java EE facile con Spring Boot - Luigi Bennardis - Codemotion Roma 2015
Codemotion
 
Madaudo
yithemes
 
SUE AGILE Architettura (Italiano)
Sabino Labarile
 
SLA Confidential
VMUG IT
 
Ignite IBB: Gabriele Loiacono - qube-os un sistema operativo web based per sv...
Toscanalab
 

Similar to Stanco delle solite Web App? Passa al Prgressive (20)

PPTX
Progressive Web App per presentazione Skills&More
FrancescoGiammanco1
 
PPTX
WordCamp Catania 2019 PWA e TWA
FrancescoGiammanco1
 
PDF
Acadevmy - PWA & Angular
Francesco Sciuti
 
PPTX
Meetup Fluent Design e Progressive Web App
dotnetcode
 
PDF
Meetup Progressive Web App
dotnetcode
 
PPTX
Progressive Web Apps
Luca Fortin
 
PDF
Creare PWA con Angular
Francesco Sciuti
 
PPTX
Come creare una PWA Progressive Web App @ Inbound Strategies 2018
Giovanni Sacheli
 
PDF
Acadevmy - PWA Overview
Francesco Sciuti
 
PPTX
Beyond the Cache sfruttare appieno le potenzialità dei Service Worker (Eduar...
EduardCapanu
 
PPTX
PWA PRESENTATION
Augusto Zanotto
 
PPTX
Pwa presentation
Augusto Zanotto
 
PPTX
Swagger pertutti
Nicolò Carandini
 
PDF
SMAU Milano 2014 GAE 24/10/2014 - IWA Italy
Paolo Dadda
 
PPTX
Social media ca’ foscari 2016
marcomurador
 
PDF
Node and the Cloud
Luciano Colosio
 
PPT
Wpo extended
stefanochiari
 
PDF
Relazione
Insubria
 
PDF
Zope zen
Maurizio Delmonte
 
PDF
Sencha touch: panoramica e orientamento sul codice
Giuseppe Toto
 
Progressive Web App per presentazione Skills&More
FrancescoGiammanco1
 
WordCamp Catania 2019 PWA e TWA
FrancescoGiammanco1
 
Acadevmy - PWA & Angular
Francesco Sciuti
 
Meetup Fluent Design e Progressive Web App
dotnetcode
 
Meetup Progressive Web App
dotnetcode
 
Progressive Web Apps
Luca Fortin
 
Creare PWA con Angular
Francesco Sciuti
 
Come creare una PWA Progressive Web App @ Inbound Strategies 2018
Giovanni Sacheli
 
Acadevmy - PWA Overview
Francesco Sciuti
 
Beyond the Cache sfruttare appieno le potenzialità dei Service Worker (Eduar...
EduardCapanu
 
PWA PRESENTATION
Augusto Zanotto
 
Pwa presentation
Augusto Zanotto
 
Swagger pertutti
Nicolò Carandini
 
SMAU Milano 2014 GAE 24/10/2014 - IWA Italy
Paolo Dadda
 
Social media ca’ foscari 2016
marcomurador
 
Node and the Cloud
Luciano Colosio
 
Wpo extended
stefanochiari
 
Relazione
Insubria
 
Sencha touch: panoramica e orientamento sul codice
Giuseppe Toto
 
Ad

More from Commit University (20)

PDF
Accessibilità ed equità digitale: un impegno, non una scelta
Commit University
 
PDF
GitHub Copilot:vediamo chi comanda - Commit University.pdf
Commit University
 
PDF
Contract Driven Development - Branch 2024.pdf
Commit University
 
PPTX
Cybersecurity & AI: Illusioni e Speranze
Commit University
 
PDF
Migliorare la Developer Experience in un mondo Cloud Native
Commit University
 
PPTX
Scopri come sfruttare la potenza della Hybrid RAG
Commit University
 
PDF
Introduzione a AWS Forecast e SageMaker DeepAR: Prevedere la Domanda con il M...
Commit University
 
PDF
Oltre l'hype: vulnerabilità e limiti dell'intelligenza artificiale.pdf
Commit University
 
PPTX
Alla scoperta dei Vector Database e dei RAG
Commit University
 
PDF
Nell’iperspazio con Rocket: il Framework Web di Rust!
Commit University
 
PDF
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Commit University
 
PDF
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Commit University
 
PDF
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Commit University
 
PDF
Slide-10years.pdf
Commit University
 
PDF
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Commit University
 
PDF
Vue.js slots.pdf
Commit University
 
PPTX
Commit - Qwik il framework che ti stupirà.pptx
Commit University
 
PPTX
Sviluppare da zero una Angular Web App per la PA
Commit University
 
PDF
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Commit University
 
PDF
Prisma the ORM that node was waiting for
Commit University
 
Accessibilità ed equità digitale: un impegno, non una scelta
Commit University
 
GitHub Copilot:vediamo chi comanda - Commit University.pdf
Commit University
 
Contract Driven Development - Branch 2024.pdf
Commit University
 
Cybersecurity & AI: Illusioni e Speranze
Commit University
 
Migliorare la Developer Experience in un mondo Cloud Native
Commit University
 
Scopri come sfruttare la potenza della Hybrid RAG
Commit University
 
Introduzione a AWS Forecast e SageMaker DeepAR: Prevedere la Domanda con il M...
Commit University
 
Oltre l'hype: vulnerabilità e limiti dell'intelligenza artificiale.pdf
Commit University
 
Alla scoperta dei Vector Database e dei RAG
Commit University
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Commit University
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Commit University
 
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Commit University
 
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Commit University
 
Slide-10years.pdf
Commit University
 
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Commit University
 
Vue.js slots.pdf
Commit University
 
Commit - Qwik il framework che ti stupirà.pptx
Commit University
 
Sviluppare da zero una Angular Web App per la PA
Commit University
 
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Commit University
 
Prisma the ORM that node was waiting for
Commit University
 
Ad

Stanco delle solite Web App? Passa al Prgressive

  • 1. Stanco delle solite web app? Passa al Progressive! Federico “Edo” Granata By
  • 2. Hello World! Io sono Federico “Edo” Granata Potete trovarmi su https://federicogranata.dev
  • 3. 1 Progressive Web App Non facciamoci intimorire
  • 4. Le caratteristiche di una PWA Veloce Secondo un sorprendente sondaggio gli utenti non apprezzano le app lente. Affidabile L’utente deve poter interagire a prescindere dalle condizioni di rete. Accattivante Una PWA è installabile, offre un’esperienza full-screen e consente di usare push notifications.
  • 5. ... ma in pratica? HTTPS Tutto il traffico DEVE essere cifrato. Manifest Un semplice file per indicare al browser che ha a che fare con una PWA. Service Worker Un JS in cui avviene la magia che consente di gestire cache e notifiche push.
  • 6. <link rel="manifest" href="/manifest.json"> { "short_name": "Maps", "name": "Google Maps", "icons": [ { "src": "/images/icons-192.png", "type": "image/png", "sizes": "192x192" }, { "src": "/images/icons-512.png", "type": "image/png", "sizes": "512x512" } ], "start_url": "/pwa/?source=pwa", "scope": "/pwa/", "display": "standalone", "background_color": "#123456", "theme_color": "#FEDCBA" } Manifest.json
  • 7. Service Worker ▪ JavaScript ▪ Separato dalla pagina ▪ Background ▪ Event Driven ▪ Magia
  • 8. ... magia? PRO ▪ Programmable Proxy ▪ Background Sync ▪ Push Notifications CONTRO ▪ DOM ▪ Nessuna persistenza
  • 9. Programmable Proxy self.addEventListener('fetch', function(event) { event.respondWith( caches.match(event.request) .then(function(response) { // Cache hit - return response if (response) { return response; } return fetch(event.request); } ) ); });
  • 10. Service Worker LifeCycle ▪ .register() ▪ Evento install ▪ Una promise viene passata a installEvent.waitUntil() ▪ Un service worker non riceve eventi e push fino a quando diventa "active". ▪ Le richieste di una pagina non passano da un service worker a meno che la pagina stessa sia passata da un service worker ▪ clients.claim() può prendere il controllo immediatamente
  • 11. <!DOCTYPE html> An image will appear here in 3 seconds: <script> navigator.serviceWorker.register('/sw.js') .then(reg => console.log('SW registered!', reg)) .catch(err => console.log('Boo!', err)); setTimeout(() => { const img = new Image(); img.src = '/dog.svg'; document.body.appendChild(img); }, 3000); </script>
  • 12. self.addEventListener('install', event => { event.waitUntil( caches.open('static-v1').then(fuction(cache) { cache.add('/cat.svg'); }); ); }); self.addEventListener('activate', event => { console.log('ready'); }); self.addEventListener('fetch', event => { const url = new URL(event.request.url); if (url.origin == location.origin && url.pathname == '/dog.svg') { event.respondWith(caches.match('/cat.svg')); } }); DEMO 1 DEMO 2
  • 13. Service Worker Update ▪ Download nuovo SW ▪ Eseguito in parallelo (riceve il suo evento install) ▪ Attende che la precedente versione non sia più in uso ▪ Oppure self.skipWaiting()
  • 14. Made Easy Workbox is a library that bakes in a set of best practices and removes the boilerplate every developer writes when working with service workers.
  • 15. Workbox ▪ Precaching ▪ Runtime caching ▪ Strategies ▪ Request routing ▪ Background sync ▪ Helpful debugging ▪ Greater flexibility and feature set than sw-precache and sw-toolbox
  • 16. Workbox Programmable Proxy - Basic workbox.routing.registerRoute( /.(?:js|css)$/, new workbox.strategies.StaleWhileRevalidate(), );
  • 17. Workbox Programmable Proxy - Intermediate workbox.routing.registerRoute( /.(?:png|gif|jpg|jpeg|svg)$/, new workbox.strategies.CacheFirst({ cacheName: 'images', plugins: [ new workbox.expiration.Plugin({ maxEntries: 60, maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days }), ], }), );
  • 18. Workbox Programmable Proxy - Advanced workbox.routing.registerRoute( /^https://fonts.gstatic.com/, new workbox.strategies.CacheFirst({ cacheName: 'google-fonts-webfonts', plugins: [ new workbox.cacheableResponse.Plugin({ statuses: [0, 200], }), new workbox.expiration.Plugin({ maxAgeSeconds: 60 * 60 * 24 * 365, }), ], }), );
  • 19. Workbox Background Sync const bgSyncPlugin = new workbox.backgroundSync.Plugin('myQueueName', { maxRetentionTime: 24 * 60 // Retry for max of 24 Hours }); workbox.routing.registerRoute( //api/.*/*.json/, new workbox.strategies.NetworkOnly({ plugins: [bgSyncPlugin] }), 'POST' );
  • 20. Workbox offre molto altro ▪ 13 moduli Service Worker ▪ 1 modulo Window ▪ Tools per automatizzare (cli, npm, gulp, grunt e webpack)
  • 21. Risorse Utili ▪ Manifest - http://bit.ly/313G047 ▪ Install - http://bit.ly/311fYOZ ▪ Service Worker - http://bit.ly/2KqBU03 ▪ SW LyfeCycle - http://bit.ly/30Hjuxb ▪ Workbox - http://bit.ly/311EAr5 ▪ PWA Starter Kit - http://bit.ly/2JU1Wau ▪ Bento Starter - http://bit.ly/2JC4ZVI ▪ PWA Checklist - http://bit.ly/313GtTV
  • 22. Thanks! ANY QUESTIONS? You can find me at: [email protected] https://federicogranata.dev http://bit.ly/Edo-LinkedIn
  • 23. CREDITS Special thanks to all the people who made and released these awesome resources for free: ▪ Presentation template by SlidesCarnival