Updating Old url to new url in PWA

Viewed 1027

I am trying to change the start_url of my PWA app from one page to another but need to understand the working. Can anyone please tell me what will happen to users of my PWA app user(with old start_url). Is there any some kind of update happen after which old user can get the updated start_url.

For example: PWA with old start_url: www.testweb.com/oldurl PWA with new start_url: www.testweb.com/newurl

will users of PWA with old URL will get any URL after I change the start_url.

1 Answers

With Chrome, it depends on whether you're on desktop or mobile. On desktop, changing the start_url will have no effect, but on Android, it should be updated within a day or two. See How Chrome handles updates to the web app manifest for details about how manifest changes affect an installed PWA.

My recommendation would be don't change the start_url but instead, use the service worker to redirect the browser to the new page. For example, you could use something like:

self.addEventListener('fetch', (event) => {
  // Check if URL is old start_url, if so redirect to new URL
  if (event.request.url.endsWith('/previous/start_url.html')) {
    const resp = Response.redirect('/new/start_url.html', 301);
    event.respondWith(resp);
  }
});
Related