fix: улучшена обработка ошибок кэширования в Service Worker
This commit is contained in:
parent
1b8ef98db0
commit
1cbb64f2f6
23
static/sw.js
23
static/sw.js
@ -2,7 +2,15 @@ const CACHE_NAME = 'salvagedb-v1';
|
|||||||
const urlsToCache = [
|
const urlsToCache = [
|
||||||
'/',
|
'/',
|
||||||
'/static/styles.css',
|
'/static/styles.css',
|
||||||
|
'/static/styles__ltr.css',
|
||||||
|
'/static/privacy.css',
|
||||||
'/static/slogo.png',
|
'/static/slogo.png',
|
||||||
|
'/static/logo2.png',
|
||||||
|
'/static/salvagedblogo.png',
|
||||||
|
'/static/favicon.ico',
|
||||||
|
'/static/faviconV2.png',
|
||||||
|
'/static/curved-arrow.png',
|
||||||
|
'/static/vin-position1.gif',
|
||||||
'/static/manifest.json',
|
'/static/manifest.json',
|
||||||
'/static/icons/icon-72x72.png',
|
'/static/icons/icon-72x72.png',
|
||||||
'/static/icons/icon-96x96.png',
|
'/static/icons/icon-96x96.png',
|
||||||
@ -22,7 +30,20 @@ self.addEventListener('install', event => {
|
|||||||
caches.open(CACHE_NAME)
|
caches.open(CACHE_NAME)
|
||||||
.then(cache => {
|
.then(cache => {
|
||||||
console.log('Opened cache');
|
console.log('Opened cache');
|
||||||
return cache.addAll(urlsToCache);
|
return Promise.all(
|
||||||
|
urlsToCache.map(url =>
|
||||||
|
fetch(url)
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Failed to fetch ${url}`);
|
||||||
|
}
|
||||||
|
return cache.put(url, response);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.warn(`Failed to cache ${url}:`, error);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Cache failed:', error);
|
console.error('Cache failed:', error);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user