If you subscribe to the notifications of some websites, you may sometimes see a strange notification with this content: “This site has been updated in the background”. What does that mean? And if you are the website owner, how can you prevent that notification?
The notifications are displayed by Chrome and look like this:
This means that the website has sent a push message to your device, has executed some code in the background to handle the incoming push message, but then it hasn’t displayed any visible notification.
This is an anomalous behavior, because push messages sent with the Push API should always produce a visible effect.
Chrome wants you to know that this is happening in background and thus displays a notification with a default message: “This site has been updated in the background”. In this way you know that the website has been active in the background for a few seconds.
Silent push (the practice to send a push message without displaying a notification) is currently not allowed due to privacy concerns and because it can lower your battery.
I am a user and I receive this notification from a website: what can I do?
Usually you can just ignore that notification: it’s not harmful and nothing to worry about.
In any case you should understand that the website displayed in the notification has been running in background, and thus may collect some information and use a little bit of battery power.
If you receive many notifications of this kind from a specific website you can consider to contact the website owner and ask to fix this. Otherwise you can even unsubscribe from the notifications.
I am a developer and I want to fix this on my website: what can I do?
If you are a web developer you need to respect this flow to avoid problems:
- You send a push message from your server
- The push message is received by the browser and activates the “push” event in the service worker
- The “push” event MUST display a notification to the user.
If you don’t respect the last step, the end users may see a default notification displayed by the browser.
The default notification is defined in the Chromium source code where you can find this explanation:
<!-- Push messaging strings --> <message name="IDS_PUSH_MESSAGING_GENERIC_NOTIFICATION_BODY" desc="Body text of an auto-generated notification informing the user that the site may have received an update in the background, in case the site did not satisfy the visible notification requirement itself."> This site has been updated in the background. </message>
Here’s some common causes:
- You are sending a push message, but the service worker is not installed properly
- You are sending a push message, but your code is not displaying a notification
- You are sending a push message, but your code exits due to an error before the notification is displayed
- You are using an HTTP request to get the notification data from your server, instead of using the notification payload (network can be unreliable when a push event is processed).
Finally, if you are having problems with your current provider, we recommend to switch to Pushpad: it is a reliable service for web push notifications that follows the best practices. If you are using Pushpad you will never see that strange notification on recent browsers and you can have peace of mind that your users are not disturbed by meaningless messages.