Skip to content

Instantly share code, notes, and snippets.


Bigger Picture biggerpicturestudio

View GitHub Profile
View sw-registration.js
if ('serviceWorker' in navigator && location.hostname !== "localhost") {
window.addEventListener('load', function() {
navigator.serviceWorker.register(‚service-worker.js’).then(function(reg) {
// updatefound is fired if service-worker.js changes.
reg.onupdatefound = function() {
var installingWorker = reg.installing;
installingWorker.onstatechange = function() {
switch (installingWorker.state) {
case 'installed':
View sw-toolbox-config.js
runtimeCaching: [{
urlPattern: /api\.feedgist\.io/,
handler: 'networkFirst'
}, {
urlPattern: /.fbcdn\.net/,
handler: 'cacheFirst'
}, {
urlPattern: /akamaihd\.net/,
handler: 'cacheFirst'
}, {
View import-sw.js
importScripts('service-worker.js'); // our Service Worker generated by sw-precache
importScripts(''); // OneSignal’s Service Worker
View .htaccess
<FilesMatch "^(OneSignalSDKWorker.*|service-worker.*|OneSignalSDKUpdaterWorker.*)\.(js)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"