Maxim Salnikov
@webmaxru
My App
As much as we love the open, unfettered Web, we're abandoning it for simpler, sleeker services [native apps] that just work
The biggest mistake we’ve made as a company is betting on HTML5 over native.
Progressive web apps use modern web APIs along with traditional progressive enhancement strategy to create cross-platform web applications.
Service Worker API
Web App Manifest
* but not everything**
** use progressive enhancement strategy
Not available in service worker:
My App
Define the set of assets required to show the minimum viable UI
Service worker
install: put the assets into Cache Storage
activate: clear Cache Storage from the previous app version assets
fetch: if the asset is in Cache Storage serve it from there. Otherwise — download and serve it (and cache it)
Build time
Register service worker the way it does not affect the app loading performance
Website/webapp
App
Service-worker
Browser/OS
Event-driven worker
Cache
fetch
push
sync
'install'
Parsed
Installing
Activating
Redundant
'activate'
Waiting
Active
self.addEventListener('install', (event) => {
// Put app's html/js/css to cache
})
self.addEventListener('activate', (event) => {
// Wipe previous version of app files from cache
})
self.addEventListener('fetch', (event) => {
if (event.request.url.indexOf('/api') != -1) {
event.respondWith(
// Network-First Strategy
)
} else {
event.respondWith(
// Cache-First Strategy
)
}
})
Maxim Salnikov
@webmaxru
Maxim Salnikov
@webmaxru