关于此工具
极简 service worker:预缓存外壳并采用缓存优先策略。
开箱即用的 sw.js——查看内容、复制,或以正确的文件名下载。免费,100% 在浏览器中运行。
极简 service worker:预缓存外壳并采用缓存优先策略。
const CACHE = 'app-v1';
const ASSETS = ['/', '/index.html', '/styles.css', '/app.js'];
self.addEventListener('install', (e) => {
e.waitUntil(caches.open(CACHE).then((c) => c.addAll(ASSETS)));
});
self.addEventListener('fetch', (e) => {
e.respondWith(caches.match(e.request).then((hit) => hit || fetch(e.request)));
});
极简 service worker:预缓存外壳并采用缓存优先策略。
开箱即用的 sw.js——查看内容、复制,或以正确的文件名下载。免费,100% 在浏览器中运行。