Skip to content

Instantly share code, notes, and snippets.

@callumacrae
Last active September 3, 2015 09:46
Show Gist options
  • Save callumacrae/5c21f1ae3fdef948316f to your computer and use it in GitHub Desktop.
Save callumacrae/5c21f1ae3fdef948316f to your computer and use it in GitHub Desktop.
Using service workers to mitigate the affect of a failing SPOF
We have a blocking script (Optimizely) in the head of our website that we have no control over and
cannot move to the footer. If this script were to somehow go down, then our site would effectively
go down, too. I was thinking about measures we could take so that if Optimizely does go down, it
doesn't take our site with it. One possible approach could be to use service workers.
36.4% of our traffic supports service workers. 28% of that is returning visitors, and will already
have the service worker installed (this is important; the service worker would be installed after
the potential failing script). That's 2700 visitors a day. We can use service workers on these
browsers to detect when Optimizely is down or very slow, and let the server know via an AJAX request.
When the server gets more than a certain number of notifications that Optimizely is down, it will
stop sending the Optimizely snippet for a period of time.
Optimizely goes down -> nobody can access the website, but browsers with a service worker already
installed send a request to the server saying so -> when server gets 10 notifications from different
IPs that optimizely is down, it turns off Optimizely so that nobody else is affected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment