Do not preload emoji annotations and i18n files
This commit is contained in:
parent
8b8f6cbca2
commit
652781fcc8
1 changed files with 5 additions and 1 deletions
|
|
@ -123,8 +123,12 @@ const isSuccessful = (resp) => {
|
||||||
self.addEventListener('install', async (event) => {
|
self.addEventListener('install', async (event) => {
|
||||||
if (shouldCache) {
|
if (shouldCache) {
|
||||||
event.waitUntil((async () => {
|
event.waitUntil((async () => {
|
||||||
|
// Do not preload i18n and emoji annotations to speed up loading
|
||||||
|
const shouldPreload = (route) => {
|
||||||
|
return !route.startsWith('/static/js/i18n/') && !route.startsWith('/static/js/emoji-annotations/')
|
||||||
|
}
|
||||||
const cache = await caches.open(cacheKey)
|
const cache = await caches.open(cacheKey)
|
||||||
await Promise.allSettled(cacheFiles.map(async (route) => {
|
await Promise.allSettled(cacheFiles.filter(shouldPreload).map(async (route) => {
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Cache/add
|
// https://developer.mozilla.org/en-US/docs/Web/API/Cache/add
|
||||||
// originally we used addAll() but it will raise a problem in one edge case:
|
// originally we used addAll() but it will raise a problem in one edge case:
|
||||||
// when the file for the route is not found, backend will return index.html with code 200
|
// when the file for the route is not found, backend will return index.html with code 200
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue