Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When and how does a PWA update itself?

As far as I know, once you click "add to homescreen" on a PWA's website, the browser generates an .apk using the provided manifest file and sources and installs it like a normal app.

I noticed that when I update the website, the app also displays the updated content which suggests that the app is just a wrapper for accessing the website. I also noticed that the update to a website is not displayed instantly, I assume this is due to internal caching.

My question is, are my assumptions correct? Or more generally, when and how are PWAs updatated and is there a way to force an update on a client machine?

like image 970
Tobias Würth Avatar asked Apr 09 '18 18:04

Tobias Würth


People also ask

How does PWA update?

The process is similar to the Chrome version. In this case, if the PWA manifest requires an update, during the next 24 hours the WebAPK will be updated on Wi-Fi after minting the updated WebAPK.

How long does a PWA last?

UX/UI Design Usually, UX/UI PWA stage duration also varies depending on the project's size and can be: 50-90 hours total for compact applications with less than average amount of functionality; 100-200 hours for midsize PWA's (most common);

How does a PWA work?

Simply put, a PWA is a website with all the benefits of an app. PWAs give you a faster, more reliable, and more engaging version of your website or eCommerce store. PWAs can do most things that native apps can do, such as operate offline, access your camera and microphone if necessary, GPS, and more.

How do you refresh a web app?

⇧ Shift-click the Refresh button. While pressing the Refresh button on your browser's address bar will only do a standard refresh, you can force a refresh from the server by pressing ⇧ Shift and clicking it instead.


1 Answers

No cache scenario (No Service worker): Your PWA app will be cached only when you use Service worker. Manifest.json will help adding your web app to home screen with a icon and open without address bar. If you don't have a service worker or if your browser don't support it, web page will be loaded fresh every single time. No Cache.

Cache-On Scenario (With Service worker): Assuming you have service workers configured, service workers can cache by lazy loading or prefetching the files that are configured for caching (You can include or exclude caching anything from html, CSS, images to JSON/XML API responses).

After the initial cache, service worker will use the cache to serve your apps network request based on cache approach you have implemented from below ones.

  • cache falling back to network
  • Network falling back to cache
  • Cache then network

Most apps choose to precache due to performance benefits and look for new files on loading, if any changes found will be loaded on next session or prompt user to refresh. With this solution, each file will have a long Hash string for each file cached by service worker. On load of each application, hash code from server will be fetched to match and find what file needs to be updated and the same will be updated in a separate service worker thread. You can notice this in network tab -> service worker response in chrome developer tools.

If you choose network-first approach, you can avoid showing old content on initial load, but loose significant performance benefits that comes with caching.

like image 58
Anand Avatar answered Oct 12 '22 07:10

Anand