After update to version 2.0.0 I have to disable onesignal plugin due to this script uses lot of cpu: wp-content/plugins/onesignal-free-web-push-notifications/sdk_files/OneSignalSDKWorker.js.php and also wp-content/plugins/onesignal-free-web-push-notifications/sdk_files/OneSignalSDKUpdaterWorker.js.php
I tested up to 2.0.2 version but it still happens.
Hi. The reason for this is that browsers implement Web Push in such a way that each user’s browser will make an HTTP request to your server when they receive a notification. This will happen for any web push notifications you send, and is not specific to OneSignal or this plugin.
If your hosting plan limits your server’s performance, then you may encounter issues when sending to a lot of subscribers.
There are four possible solutions to this problem:
1. Implement a CDN like Cloudflare to cache files so that requests are handled by your CDN instead of your server. Cloudflare is a good free option for this.
2. Upgrade to a more powerful server or hosting plan that can handle the larger amount of traffic.
3. Send notifications to a smaller group of people (eg: by segmenting your audience and sending to a smaller group in the OneSignal dashboard).
4. Move OneSignal’s server worker files to be served as static files instead of dynamic files, which can reduce CPU usage. (Advanced)
For more information on the technical reasons why browsers make a request to your server when a notification is received, you can read about Servie Workers, which are used to handle web push notifications in the browser (1), and the Service Worker Lifecycle (2).
This was really helpful. I used Cloudflare page rules and it worked properly.
This is a helpful youtube video on how to use the page rules:
I used something similar to this URL matcher:
*mywebsite.com/wp-content/plugins/onesignal-free-web-push-notifications/sdk_files/OneSignalSDKWorker.js.php*