New logic to detect PWA offline support

Chrome for Developers · Intermediate ·📰 AI News & Updates ·5y ago

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 Polymer Performance Patterns (The Polymer Summit 2015)
Polymer Performance Patterns (The Polymer Summit 2015)
Chrome for Developers
2 Polymer Power Tools (The Polymer Summit 2015)
Polymer Power Tools (The Polymer Summit 2015)
Chrome for Developers
3 Chrome Dev Summit 2014 – Chrome Case Studies
Chrome Dev Summit 2014 – Chrome Case Studies
Chrome for Developers
4 Web Directions Code 2015 round up
Web Directions Code 2015 round up
Chrome for Developers
5 Maintainable Code - HTTP203
Maintainable Code - HTTP203
Chrome for Developers
6 iron-ajax… wat?! -- Polycasts #26
iron-ajax… wat?! -- Polycasts #26
Chrome for Developers
7 The Guardian - Supercharged
The Guardian - Supercharged
Chrome for Developers
8 ES2015 (next version of JavaScript), Totally Tooling Tips (S2 Ep1)
ES2015 (next version of JavaScript), Totally Tooling Tips (S2 Ep1)
Chrome for Developers
9 #AskPolymer: Rob answers all the questions ever -- Polycasts #27
#AskPolymer: Rob answers all the questions ever -- Polycasts #27
Chrome for Developers
10 The Future of JavaScript - HTTP203
The Future of JavaScript - HTTP203
Chrome for Developers
11 Data Binding 101 -- Polycasts #28
Data Binding 101 -- Polycasts #28
Chrome for Developers
12 The Guardian part 2 - Supercharged
The Guardian part 2 - Supercharged
Chrome for Developers
13 The Future of Web Audio: with Chris Wilson and Chris Lowis
The Future of Web Audio: with Chris Wilson and Chris Lowis
Chrome for Developers
14 Chrome 46: New motion-path animations, client hints and service worker improvements
Chrome 46: New motion-path animations, client hints and service worker improvements
Chrome for Developers
15 Sublime Snippets, Totally Tooling Tips (S2 Ep2)
Sublime Snippets, Totally Tooling Tips (S2 Ep2)
Chrome for Developers
16 #AskPolymer: How do you make the show? -- Polycasts #29
#AskPolymer: How do you make the show? -- Polycasts #29
Chrome for Developers
17 Critical Path CSS, Totally Tooling Tips (S2 Mini Tip #1)
Critical Path CSS, Totally Tooling Tips (S2 Mini Tip #1)
Chrome for Developers
18 Binding to Objects -- Polycasts #30
Binding to Objects -- Polycasts #30
Chrome for Developers
19 Player FM - Supercharged
Player FM - Supercharged
Chrome for Developers
20 Where’s the Designer? #AskPolymer -- Polycasts #31
Where’s the Designer? #AskPolymer -- Polycasts #31
Chrome for Developers
21 Jake Beats Wikipedia - HTTP203
Jake Beats Wikipedia - HTTP203
Chrome for Developers
22 Supercharged Observers! -- Polycasts #32
Supercharged Observers! -- Polycasts #32
Chrome for Developers
23 Jai's Web blog - Supercharged
Jai's Web blog - Supercharged
Chrome for Developers
24 Windows Command-line Tooling, Totally Tooling Tips (S2, Ep4)
Windows Command-line Tooling, Totally Tooling Tips (S2, Ep4)
Chrome for Developers
25 What about internationalization? #AskPolymer -- Polycasts #33
What about internationalization? #AskPolymer -- Polycasts #33
Chrome for Developers
26 Developing for Billions (Chrome Dev Summit 2015)
Developing for Billions (Chrome Dev Summit 2015)
Chrome for Developers
27 Google+ Performance Improvement Comparison
Google+ Performance Improvement Comparison
Chrome for Developers
28 Deploying HTTPS: The Green Lock and Beyond (Chrome Dev Summit 2015)
Deploying HTTPS: The Green Lock and Beyond (Chrome Dev Summit 2015)
Chrome for Developers
29 Progressive Web Apps (Chrome Dev Summit 2015)
Progressive Web Apps (Chrome Dev Summit 2015)
Chrome for Developers
30 Instant Loading with Service Workers (Chrome Dev Summit 2015)
Instant Loading with Service Workers (Chrome Dev Summit 2015)
Chrome for Developers
31 Increase Engagement with Web Push Notifications (Chrome Dev Summit 2015)
Increase Engagement with Web Push Notifications (Chrome Dev Summit 2015)
Chrome for Developers
32 Engaging with the Real World: Web Bluetooth and Physical Web (Chrome Dev Summit 2015)
Engaging with the Real World: Web Bluetooth and Physical Web (Chrome Dev Summit 2015)
Chrome for Developers
33 Asking for Permission: respectful, opinionated UI (Chrome Dev Summit 2015)
Asking for Permission: respectful, opinionated UI (Chrome Dev Summit 2015)
Chrome for Developers
34 Polymer - State of the Union (Chrome Dev Summit 2015)
Polymer - State of the Union (Chrome Dev Summit 2015)
Chrome for Developers
35 Building Progressive Web Apps with Polymer (Chrome Dev Summit 2015)
Building Progressive Web Apps with Polymer (Chrome Dev Summit 2015)
Chrome for Developers
36 Introduction to RAIL (Chrome Dev Summit 2015)
Introduction to RAIL (Chrome Dev Summit 2015)
Chrome for Developers
37 DevTools in 2015: Authoring to the max (Chrome Dev Summit 2015)
DevTools in 2015: Authoring to the max (Chrome Dev Summit 2015)
Chrome for Developers
38 RAIL in the real world (Chrome Dev Summit 2015)
RAIL in the real world (Chrome Dev Summit 2015)
Chrome for Developers
39 #ChromeDevSummit talks are up - W00T! -- Polycast #34
#ChromeDevSummit talks are up - W00T! -- Polycast #34
Chrome for Developers
40 V8 Performance from the Driver's Seat (Chrome Dev Summit 2015)
V8 Performance from the Driver's Seat (Chrome Dev Summit 2015)
Chrome for Developers
41 Quantify and improve real-world RAIL (Chrome Dev Summit 2015)
Quantify and improve real-world RAIL (Chrome Dev Summit 2015)
Chrome for Developers
42 Owning your performance: RAIL (Chrome Dev Summit 2015)
Owning your performance: RAIL (Chrome Dev Summit 2015)
Chrome for Developers
43 HTTP/2 101 (Chrome Dev Summit 2015)
HTTP/2 101 (Chrome Dev Summit 2015)
Chrome for Developers
44 Leadership Panel (Chrome Dev Summit 2015)
Leadership Panel (Chrome Dev Summit 2015)
Chrome for Developers
45 Build Processes, Totally Tooling Tips (S2, Ep 5)
Build Processes, Totally Tooling Tips (S2, Ep 5)
Chrome for Developers
46 Accessibility (Chrome Dev Summit 2015)
Accessibility (Chrome Dev Summit 2015)
Chrome for Developers
47 Binding to Arrays -- Polycasts #35
Binding to Arrays -- Polycasts #35
Chrome for Developers
48 HTTP2 - HTTP203
HTTP2 - HTTP203
Chrome for Developers
49 Chrome 47: Splash Screens, requestIdleCallback and better desktop notifications (New in Chrome)
Chrome 47: Splash Screens, requestIdleCallback and better desktop notifications (New in Chrome)
Chrome for Developers
50 Call For Submissions - Supercharged
Call For Submissions - Supercharged
Chrome for Developers
51 Cross Device Testing, Totally Tooling Tips (S2 Ep6)
Cross Device Testing, Totally Tooling Tips (S2 Ep6)
Chrome for Developers
52 Testing AJAX with Web Component Tester -- Polycasts #37
Testing AJAX with Web Component Tester -- Polycasts #37
Chrome for Developers
53 Slack: Extended Xmas Special - Supercharged
Slack: Extended Xmas Special - Supercharged
Chrome for Developers
54 Browser testing with Travis & Sauce Labs -- Polycasts #38
Browser testing with Travis & Sauce Labs -- Polycasts #38
Chrome for Developers
55 Optimize for production with Vulcanize -- Polycasts #39
Optimize for production with Vulcanize -- Polycasts #39
Chrome for Developers
56 Highlights from Chrome Dev Summit 2015
Highlights from Chrome Dev Summit 2015
Chrome for Developers
57 Chrome 48: Custom buttons in notifications, DevTools Security panel, and Presentation mode
Chrome 48: Custom buttons in notifications, DevTools Security panel, and Presentation mode
Chrome for Developers
58 Crisper: Protecting your Polymer app with CSP -- Polycasts #40
Crisper: Protecting your Polymer app with CSP -- Polycasts #40
Chrome for Developers
59 How do I use Sass with Polymer? #AskPolymer -- Polycasts #41
How do I use Sass with Polymer? #AskPolymer -- Polycasts #41
Chrome for Developers
60 Colors – DevTools Tonight #0 (Pilot)
Colors – DevTools Tonight #0 (Pilot)
Chrome for Developers

Chrome is introducing a new logic to detect PWA offline support, ensuring a better user experience by checking if a PWA can respond with a 200 response to a fake HTTP request without an internet connection. Developers can use Workbox to easily support offline pages.

Key Takeaways
  1. Check if your PWA has a manifest.json with the correct fields
  2. Implement a service worker with a fetch event handler
  3. Use Workbox to cache resources and support offline pages
  4. Test your PWA's offline capability using Chrome's new detection logic
💡 The new offline capability detection logic checks for a 200 response to a fake HTTP request, ensuring that PWAs work correctly without an internet connection.

Related Reads

📰
The AI giants just broke with OpenAI and Anthropic on open weights
25 AI companies publish open letter urging Washington not to restrict open-weight AI, learn why and how it impacts AI development
The Next Web AI
📰
Meta leaves RE100 clean energy pact after a decade as its gas buildout for AI outpaces renewables
Meta leaves RE100 clean energy pact due to gas buildout for AI, highlighting the challenge of balancing energy demands with sustainability goals
The Next Web AI
📰
AI As The Official Reason You Got Laid Off
Learn how AI is being used as a justification for layoffs and what's really happening behind the scenes
Medium · AI
📰
I Priced an AI Side Hustle. It Runs $60 a Month.
Learn how to estimate the costs of running an AI side hustle, which can be as low as $60 a month
Medium · AI
Up next
How SpaceX Holds the World's Biggest Rocket
Silism
Watch →