Have you ever wondered what happens to the subscribers that receive your notifications if you decide to migrate to a new domain?
The first thing to notice is that the push subscriptions are bound to a domain and cannot be transferred to a new domain. This is how the Push API standard works.
Usually, in this case, you will add a permanent redirect (301) from the old domain to the new domain, in order to send the users to the new domain and to preserve the domain authority.
Let's say that you have added a wildcard redirect from example.org
to the new domain example.com
.
When a user that was subscribed to the notifications on example.org
receives a new push message, the browser activates the service worker (e.g. https://example.org/service-worker.js
) and displays the notification normally.
The problems start when the browser tries to refresh the service worker. In this case it may find that the service worker is redirected to a new domain: this is not supported and the update of the service worker fails. The old version of the service worker should remain installed.
This means that the service worker and web push notifications may still work for some time on the old domain: we have tested this on Chrome (v116) and chromium-based browsers and it worked. However it is temporary and, since it is an edge case, it is not guaranteed to work an all browsers and versions.
It is still useful to send a notification to all users and ask them to subscribe to the notifications again on the new domain.
The subscriptions on the new domain are completely different subscriptions, that are separate from those on the original domain.
If you use PusherStudio, we suggest using a new project for the new domain (so that you can easily distinguish the subscription lists and eventually delete the old subscribers).
Tip: on the old domain, if it's possible, create a redirect for all the URLs except for the service-worker.js
file. In this way the service worker will remain functional (we haven't tested this directly, but it should work).
Add New Comment