Got a problem where some of our users have a buggy Service Worker sitting in their Facebook Browsers from our sites.
The problem: Facebook App users are getting our 'you are offline page' on the FB browser when they access our pages shared on FB.
The bug appeared to be that an old version of Google's Workbox (3.6.1) was automatically returning the 'You Are Offline' page in the FB app using Chrome 75. Updating Workbox fixed it.
The reference to Workbox was in the service worker, so when we updated our Workbox version (which fixed the issue) some users still had the old one cached.
If users clear their FB App caches or reinstall FB, then all's well and they can see our content. But we'd like to try to force the SW to update without asking them to do that.
To wipe the old Service Worker out from the FB browser, we tried the following:
<script>
"use strict";
console.log("Service Worker Registration");
function isFacebookApp() {
var ua = navigator.userAgent || navigator.vendor || window.opera;
return (ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1);
}
if ("serviceWorker" in navigator) {
if(isFacebookApp() == true) {
console.log("Service Worker Registration: using v2, via Facebook App");
navigator.serviceWorker.getRegistrations().then(function(registrations) {
for(let registration of registrations) {
console.log("Service Worker Registration: "+registration);
registration.unregister();
}
});
} else {
console.log("Service Worker Registration: using v2, not via Facebook App");
window.addEventListener("load", () => {
navigator.serviceWorker.register("/sw.js");
});
}
}
</script>
However our analytics show that we're still getting hits on the You Are Offline page, and we're still getting reports from users that they can's follow links to our articles.
Can anyone help? Is there a way of forcing FB's in-app browser to update the cache, and get our users using a working Service Worker?
Update
So far we have tried:
skipWaiting()
in the Service Worker code/offline
page resulted in net::ERR_FAILED
errorOur analytics indicate the following:
Nothing's worked: our Service Worker, or something, is still returning the Offline page...
This is a bug in Chrome/the Chromium WebView, tracked in https://bugs.chromium.org/p/chromium/issues/detail?id=977784
The fix should be broadly rolled out at this point.
we experienced the same problem but presenting slightly differently - our users began receiving an error message "net:: ERR FAILED" though it sounds like the same cause. The problem began around 10 days ago, and the only way I've managed to get around the cache is to send the users to a new version of the site - by removing the www. from the URL that I'm sending to, and stopping this from 301'ing to with the www.
I also tried a bunch of solutions like you have, but it doesn't seem to be possible to get the service worker to contact the website - if you put Charles between your phone and the internet you'll see no traffic reaches your site. I'm hoping that after a period of disuse the service worker will be cleaned up by the app cache and we can switch back. Sorry I can't be more help, but rest assured you're not alone!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With