-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Flag for enabling cache in production | ||
var doCache = false; | ||
|
||
var CACHE_NAME = "pwa-app-cache"; | ||
|
||
// Delete old caches | ||
self.addEventListener("activate", (event) => { | ||
const currentCachelist = [CACHE_NAME]; | ||
event.waitUntil( | ||
caches.keys().then((keyList) => | ||
Promise.all( | ||
keyList.map((key) => { | ||
if (!currentCachelist.includes(key)) { | ||
return caches.delete(key); | ||
} | ||
}) | ||
) | ||
) | ||
); | ||
}); | ||
|
||
// This triggers when user starts the app | ||
self.addEventListener("install", function (event) { | ||
if (doCache) { | ||
event.waitUntil( | ||
caches.open(CACHE_NAME).then(function (cache) { | ||
fetch("asset-manifest.json") | ||
.then((response) => { | ||
response.json(); | ||
}) | ||
.then((assets) => { | ||
// We will cache initial page and the main.js | ||
// We could also cache assets like CSS and images | ||
const urlsToCache = ["/", assets["main.js"]]; | ||
cache.addAll(urlsToCache); | ||
}); | ||
}) | ||
); | ||
} | ||
}); | ||
|
||
// Here we intercept request and serve up the matching files | ||
self.addEventListener("fetch", function (event) { | ||
if (doCache) { | ||
event.respondWith( | ||
caches.match(event.request).then(function (response) { | ||
return response || fetch(event.request); | ||
}) | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"short_name": "SQL Playground", | ||
"name": "SQL Playground", | ||
"icons": [ | ||
{ | ||
"src": "favicon.png", | ||
"sizes": "512x512 64x64 32x32 24x24 16x16", | ||
"type": "image/png" | ||
} | ||
], | ||
"start_url": ".", | ||
"display": "standalone", | ||
"theme_color": "#003eb3", | ||
"background_color": "#ffffff" | ||
} |