pre cache in service worker

18 views Asked by At

Is is correct to have this kind of path in precaching? Ive tried to change into this but still not working

const PRECACHE_ASSETS = [
    `/Content/js/application/web.home.index.js`,
    `/Areas/Web/Views/Home/Index.cshtml`,
];


const CACHE_NAME = 'my-cache';

 //Add whichever assets you want to pre-cache here:
const pages = ['Home/Index', 'Careers/Index', 'Careers/Opening', 'Success/Index'];
const jsFiles = pages.map(page => `/Content/js/application/web.${page.toLowerCase()}.js`);
const cssFiles = pages.map(page => `/Content/css/application/web.${page.toLowerCase()}.css`);
const htmlFiles = pages.map(page => `/Web/Views/${page}.cshtml`);

const PRECACHE_ASSETS = [
    ...htmlFiles,
    ...jsFiles,
    ...cssFiles,
];

self.addEventListener('install', event => {
    event.waitUntil((async () => {
        const cache = await caches.open(CACHE_NAME);
        cache.addAll(PRECACHE_ASSETS);
    })());
});
0

There are 0 answers