This document discusses progressive web apps (PWAs). It explains that PWAs are websites that behave like native mobile apps through features such as working offline, push notifications, and loading quickly. It provides steps for migrating an existing website to a PWA, including adding HTTPS, caching assets, adding to the home screen, and using service workers to handle offline states. It also covers caching strategies, the web app manifest, and using service workers to cache assets, handle push notifications, and more. The document aims to explain the key concepts and technologies that power PWAs.
8. PWA Power โ Gabriele Falasca
SSR โ Server Side Rendering
1. SERVER RETURNS A COMPLETE STATIC PAGE
2. PAGE LOADS REMOTE CSS, JS AND ASSETS
3. EVERY ACTION ON THE PAGE CAUSES A BROWSER
RELOAD
9. PWA Power โ Gabriele Falasca
CSR โ CLIENT Side Rendering
1. SERVER RETURNS AN EMPTY PAGE (TEMPLATE)
2. JS MAKES REQUESTS TO GET PAGE CONTENT
3. EVERY ACTION ON THE PAGE RELOAD ONLY
DYNAMIC CONTENT
10. PWA Power โ Gabriele Falasca
SSR caching strategies
1. CACHE CSS JS AND ASSETS
2. IF THE APP HAS A STATIC PAGE CACHE IT TOO
3. JS CAN HANDLE OFFLINE STATE
11. PWA Power โ Gabriele Falasca
CSR caching strategies
1. CACHE CSS, JS, TEMPLATE AND ASSETS
2. CACHE DATA USING CACHE API OR INDEXEDDB
(i prefer IndexedDB)
3. DETECT OFFLINE STATE THROUGH JAVASCRIPT
12. PWA Power โ Gabriele Falasca
Detect offline state - JS
if(navigator.offline)
OR
navigator.addEventListener(โofflineโ, โฆ)
navigator.addEventListener(onlineโ, โฆ)
17. PWA Power โ Gabriele Falasca
Service Workers
Service workers essentially act as proxy servers that sit between
web applications, the browser, and the network (when available).
They are intended, among other things, to enable the creation of
effective offline experiences, intercept network requests and take
appropriate action based on whether the network is available, and
update assets residing on the server. They will also allow access to
push notifications and background sync APIs
(source: https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API)
18. PWA Power โ Gabriele Falasca
Register a service worker for your application
ServiceWorkerContainer.register(scriptURL, options)
.then(function(ServiceWorkerRegistrationObject) {
โฆ
// do some stuff
โฆ
});
19. PWA Power โ Gabriele Falasca
What you can do with Service Worker?
1. CACHING THINGS
2. REGISTER FOR PUSH NOTIFICATION
3. USE WEB PAYMENT API
4. AND MANY MANY MOREโฆ