New logic to detect PWA offline support
Key Takeaways
Chrome's new logic to detect PWA offline support, improving the user experience by ensuring PWAs work correctly without an internet connection, and introducing a new offline capability detection logic that checks for a 200 response to a fake HTTP request.
Full Transcript
[Music] hi everyone my name is asami i'm a software engineer in the chrome browser team today i'm gonna talk about the new logic to detect pwa offline support pwa is a technology to turn a web application into a native app like stuff so that we can take advantage of both web and native app features because pwa offers native up-like experience for websites websites that support pwa can be installed as if they were native apps when you visit and offline capable pwa the browser asks if you want to install it if your answer is yes the icon for the pwa is added to the app launcher on desktop and to home screen on mobile once installed pwa can add should work even without internet connection let's see a little bit more about the flow of how to install a pwa if you want to install a pwa on desktop first you visit our pwa capable website and the click pressing cycle button in omnibox then you can see the install popup you can install a pwa by clicking the install button now you can see the icon in chrome current slash apps in the browser when you install api on mobile the icon will appear on home screen like this however when you open uninstalled pwa without an internet connection you sometimes see the screen the dinosaur page telling us no internet connection this is so frustrating and definitely not an app-like user experience right this is a problem we are currently improving we are hoping all pwas work correctly without an internet connection we encourage web developers to make their pwas work offline by handling the offline situation correctly so we are raising the bar for website to display the pwa install prompts in short if your pwa doesn't work offline chrome will not show the prompts for installation starting from the near future that change will affect both mobile and desktop before we dive into how to check offline capability of a site let me quickly review four requirements to make vwa installable you need a manifest json with a correct field fielding a secure domain icons and a service worker to allow the app to work offline when the site satisfy all of the requirements install buttons will show up on mobile you can see an install button in the three dot menu and add to home screen button at the bottom of the page when the site satisfies the requirements on desktop you can see a processing cycle button in opening box and an install button in the three dot menu when the site satisfies the requirements service worker is a thing that is responsible for offline support here is how it works service worker can install a fetch event handler to steal or interrupt http request from the pwa before they get to the network using the feature service worker can and is expected to handle all http requests by itself when you're offline a fetch event tundra is expected to return resources on behalf of actual website using cache resources as if an internet connection is available the behavior should be implemented by developers if it's not implemented the install prompts wouldn't appear but the problem is the logic to detect if the site works offline is not very accurate consequently install prompts may appear even if the site doesn't actually support offline correctly this is a reason why you sometimes see the dinosaur page in an installed pwa the current logic to detect pwl offline support is just checking the existence of a fetch event tundra in service worker i mean even an empty event chandra like this is considered an offline support but what happens if a fetch event tundra is empty in a fetch event tundra is empty it does nothing so http request fail it leads to the dinosaur page this is a problem that i'm working on right now concretely speaking chrome will stop considering the empty event handler as an offline support we are updating the offline capability detection logic as follows in the new logic chrome will create a fake http request and send it to a pwa mains page which is specified as start url in manifest.json to see if the pwa responds with a 200 response during the test pwa runs in a sandbox that doesn't have an internet connection a pwa is considered offline capable if and only if it returns a 200 response for the fake request this is a naive and simplest example in service worker that can be considered as offline capable the fetch event handler returns a response object when a fetch request fails so users can see hero or front page text when they access uninstalled pwa offline this is another example in subs worker that can be considered as offline capable this code use cash straight to store resources when users install a service worker online once users install a service worker and store resources to cash straight the fetch event handler can return the resources without internet connection this is yet another example with workbox workbox is a javascript library to make it easy to support offline pages first you need to supply an array of resources to the pre-cache and root method it will do caching as soon as the service worker is activated second you can use the navigation route method to return a specific response for all navigation requests using workbox is easy and practical so we recommend using it for your site here is a timeline we are currently planning the new offline detection logic is not available yet but most implementation was done in the current stable chrome version 87. in the next milestone chrome 88 the future is enabled behind the flag you can enable check-offline k-puppetry flag in chrome current slash flux also we are going to run experiment for some dev and canary users to make sure any regression doesn't happen we are planning to roll out the future in chrome 89 with warning mode the winding mode means that new check happens without enforcement it will show a running message in the developer console if the site doesn't pass a new offline capability detection logic after a grace period the new requirement will be enforced to all sites we are very excited to see the new offering detection logic and we believe that it will lead to a better user experience we welcome your feedback so please input what you think about the new offering capability check thank you
Original Description
PWA install prompt (e.g. a “plus-in-circle” icon in Chrome's Omnibox) enables users to install a website. Currently, Chrome shows the PWA install prompts whenever a site has a manifest.json with the correct fields filled in, a secure domain and icons, and a service worker with a fetch handler, with the expectation that such a site will work offline. However, some PWAs can show the install prompts although they do not support offline pages by installing an empty fetch event handler in a service worker. This leads to unexpected behavior for users such as showing the dinosaur page which tells no internet connection. Chrome proposes changing the logic to raise the bar to show the prompts. Concretely, Chrome will actually invoke a fetch event handler with a fake request to see if the handler returns a response with 200 status code, which is a strong signal that the site actually supports the offline capability. The PWA install prompts show up only when a site has a fetch event handler which returns a response with 200 status code.
This new logic is not available yet. Chrome will run experiments to see how many websites are affected and make sure that the new logic will not cause an unacceptable delay to the page loading time. Chrome will ship the feature after sufficient announcements have been made.
Resources:
New logic to detect offline support in PWAs → https://goo.gle/improved-pwa-offline-detection
Let us know what you think of these changes → https://goo.gle/pwa-offline-feedback
Chromium tracking bug → https://goo.gle/3pZIAEL
Speaker: Asami Doi
Subscribe to Google Chrome Developers here → https://goo.gle/ChromeDevs
Watch all Chrome Developer Summit sessions here → https://goo.gle/cds20-sessions
#chromedevsummit #chrome #pwa
event: Chrome Dev Summit 2020; re_ty: Publish; product: Chrome - General; fullname: Asami Doi;
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Chrome for Developers · Chrome for Developers · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Polymer Performance Patterns (The Polymer Summit 2015)
Chrome for Developers
Polymer Power Tools (The Polymer Summit 2015)
Chrome for Developers
Chrome Dev Summit 2014 – Chrome Case Studies
Chrome for Developers
Web Directions Code 2015 round up
Chrome for Developers
Maintainable Code - HTTP203
Chrome for Developers
iron-ajax… wat?! -- Polycasts #26
Chrome for Developers
The Guardian - Supercharged
Chrome for Developers
ES2015 (next version of JavaScript), Totally Tooling Tips (S2 Ep1)
Chrome for Developers
#AskPolymer: Rob answers all the questions ever -- Polycasts #27
Chrome for Developers
The Future of JavaScript - HTTP203
Chrome for Developers
Data Binding 101 -- Polycasts #28
Chrome for Developers
The Guardian part 2 - Supercharged
Chrome for Developers
The Future of Web Audio: with Chris Wilson and Chris Lowis
Chrome for Developers
Chrome 46: New motion-path animations, client hints and service worker improvements
Chrome for Developers
Sublime Snippets, Totally Tooling Tips (S2 Ep2)
Chrome for Developers
#AskPolymer: How do you make the show? -- Polycasts #29
Chrome for Developers
Critical Path CSS, Totally Tooling Tips (S2 Mini Tip #1)
Chrome for Developers
Binding to Objects -- Polycasts #30
Chrome for Developers
Player FM - Supercharged
Chrome for Developers
Where’s the Designer? #AskPolymer -- Polycasts #31
Chrome for Developers
Jake Beats Wikipedia - HTTP203
Chrome for Developers
Supercharged Observers! -- Polycasts #32
Chrome for Developers
Jai's Web blog - Supercharged
Chrome for Developers
Windows Command-line Tooling, Totally Tooling Tips (S2, Ep4)
Chrome for Developers
What about internationalization? #AskPolymer -- Polycasts #33
Chrome for Developers
Developing for Billions (Chrome Dev Summit 2015)
Chrome for Developers
Google+ Performance Improvement Comparison
Chrome for Developers
Deploying HTTPS: The Green Lock and Beyond (Chrome Dev Summit 2015)
Chrome for Developers
Progressive Web Apps (Chrome Dev Summit 2015)
Chrome for Developers
Instant Loading with Service Workers (Chrome Dev Summit 2015)
Chrome for Developers
Increase Engagement with Web Push Notifications (Chrome Dev Summit 2015)
Chrome for Developers
Engaging with the Real World: Web Bluetooth and Physical Web (Chrome Dev Summit 2015)
Chrome for Developers
Asking for Permission: respectful, opinionated UI (Chrome Dev Summit 2015)
Chrome for Developers
Polymer - State of the Union (Chrome Dev Summit 2015)
Chrome for Developers
Building Progressive Web Apps with Polymer (Chrome Dev Summit 2015)
Chrome for Developers
Introduction to RAIL (Chrome Dev Summit 2015)
Chrome for Developers
DevTools in 2015: Authoring to the max (Chrome Dev Summit 2015)
Chrome for Developers
RAIL in the real world (Chrome Dev Summit 2015)
Chrome for Developers
#ChromeDevSummit talks are up - W00T! -- Polycast #34
Chrome for Developers
V8 Performance from the Driver's Seat (Chrome Dev Summit 2015)
Chrome for Developers
Quantify and improve real-world RAIL (Chrome Dev Summit 2015)
Chrome for Developers
Owning your performance: RAIL (Chrome Dev Summit 2015)
Chrome for Developers
HTTP/2 101 (Chrome Dev Summit 2015)
Chrome for Developers
Leadership Panel (Chrome Dev Summit 2015)
Chrome for Developers
Build Processes, Totally Tooling Tips (S2, Ep 5)
Chrome for Developers
Accessibility (Chrome Dev Summit 2015)
Chrome for Developers
Binding to Arrays -- Polycasts #35
Chrome for Developers
HTTP2 - HTTP203
Chrome for Developers
Chrome 47: Splash Screens, requestIdleCallback and better desktop notifications (New in Chrome)
Chrome for Developers
Call For Submissions - Supercharged
Chrome for Developers
Cross Device Testing, Totally Tooling Tips (S2 Ep6)
Chrome for Developers
Testing AJAX with Web Component Tester -- Polycasts #37
Chrome for Developers
Slack: Extended Xmas Special - Supercharged
Chrome for Developers
Browser testing with Travis & Sauce Labs -- Polycasts #38
Chrome for Developers
Optimize for production with Vulcanize -- Polycasts #39
Chrome for Developers
Highlights from Chrome Dev Summit 2015
Chrome for Developers
Chrome 48: Custom buttons in notifications, DevTools Security panel, and Presentation mode
Chrome for Developers
Crisper: Protecting your Polymer app with CSP -- Polycasts #40
Chrome for Developers
How do I use Sass with Polymer? #AskPolymer -- Polycasts #41
Chrome for Developers
Colors – DevTools Tonight #0 (Pilot)
Chrome for Developers
Related Reads
📰
📰
📰
📰
The AI giants just broke with OpenAI and Anthropic on open weights
The Next Web AI
Meta leaves RE100 clean energy pact after a decade as its gas buildout for AI outpaces renewables
The Next Web AI
AI As The Official Reason You Got Laid Off
Medium · AI
I Priced an AI Side Hustle. It Runs $60 a Month.
Medium · AI
🎓
Tutor Explanation
DeepCamp AI