提问人:Erika Mae Baldove 提问时间:11/15/2023 更新时间:11/15/2023 访问量:10
Service Worker 中的预缓存
pre cache in service worker
问:
在预缓存中拥有这种路径是正确的吗? 我试图改变这个,但仍然不起作用
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);
})());
});
答: 暂无答案
评论