Cache correct assets (#887)

* Cache correct assets

* Update lib/entry-data-plugin.js

Co-authored-by: Surma <surma@surma.dev>

* Actually commit the fix this time

Co-authored-by: Surma <surma@surma.dev>
This commit is contained in:
Jake Archibald
2020-12-09 12:20:14 +00:00
committed by GitHub
parent fec826b106
commit 9062a75541
9 changed files with 330 additions and 78 deletions

View File

@@ -19,11 +19,11 @@ self.addEventListener('install', (event) => {
event.waitUntil(
(async function () {
const promises = [];
promises.push(cacheBasics(versionedCache, ASSETS));
promises.push(cacheBasics(versionedCache));
// If the user has already interacted with the app, update the codecs too.
if (await get('user-interacted')) {
promises.push(cacheAdditionalProcessors(versionedCache, ASSETS));
promises.push(cacheAdditionalProcessors(versionedCache));
}
await Promise.all(promises);
@@ -53,6 +53,11 @@ self.addEventListener('fetch', (event) => {
// Don't care about other-origin URLs
if (url.origin !== location.origin) return;
if (url.pathname === '/editor') {
event.respondWith(Response.redirect('/'));
return;
}
if (
url.pathname === '/' &&
url.searchParams.has('share-target') &&
@@ -77,7 +82,7 @@ self.addEventListener('fetch', (event) => {
self.addEventListener('message', (event) => {
switch (event.data) {
case 'cache-all':
event.waitUntil(cacheAdditionalProcessors(versionedCache, ASSETS));
event.waitUntil(cacheAdditionalProcessors(versionedCache));
break;
case 'skip-waiting':
self.skipWaiting();