Skip to content

Commit

Permalink
更新依赖和设置
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacharia2 committed Oct 2, 2023
1 parent 34dbe56 commit 404c43b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"devDependencies": {
"cross-env": "7.0.3",
"html-minifier-terser": "7.2.0",
"rimraf": "^5.0.5",
"shx": "0.3.4",
"tiddlywiki": "^5.3.0",
"tiddlywiki": "^5.3.1",
"uglify-js": "3.17.4",
"workbox-cli": "7.0.0",
"zx": "^7.2.2",
"rimraf": "^5.0.1"
"zx": "^7.2.3"
}
}
9 changes: 2 additions & 7 deletions public/manifest.webmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
"display": "standalone",
"icons": [
{
"src": "/TiddlyWikiIconBlack.png",
"src": "/favicon.ico",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "/TiddlyWikiIconWhite.png",
"sizes": "144x144",
"type": "image/png"
"type": "image/x-icon"
}
],
"name": "TiddlyWiki",
Expand Down
24 changes: 8 additions & 16 deletions public/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.4/workbox-sw.js');
importScripts('https://cdn.bootcdn.net/ajax/libs/workbox-sw/7.0.0/workbox-sw.js');

if (workbox) {
console.log(`Yay! Workbox is loaded 🎉Service Worker is working!`);
Expand Down Expand Up @@ -38,21 +38,13 @@ registerRoute(
})
);

registerRoute(/\.js$/, new StaleWhileRevalidate());


/*
可选的html缓存策略,StaleWhileRevalidate、NetworkFirst
StaleWhileRevalidate:当请求的路由有对应的Cache缓存结果就直接返回,
在返回Cache缓存结果的同时会在后台发起网络请求拿到请求结果并更新Cache缓存,
如果本来就没有Cache缓存的话,就直接发起网络请求并返回结果,
这对用户来说是一种非常安全的策略.
NetworkFirst:当请求的路由是被匹配的,就采用网络优先的策略,也就是
优先尝试拿到网络请求的返回结果,如果拿到网络请求的结果,就将结果返回
给客户端并且写入Cache缓存,如果网络请求失败,那最后被缓存的Cache缓
存结果就会被返回到客户端,这种策略一般适用于返回结果不太固定或对实时性
有要求的请求,为网络请求失败进行兜底。
可选的html缓存策略,StaleWhileRevalidate、NetworkFirst。
*/

registerRoute(/\.js$/, new StaleWhileRevalidate());
registerRoute(/(^\/$|index.html)/, new StaleWhileRevalidate());

self.addEventListener('install', (e) => {
self.skipWaiting();
});

0 comments on commit 404c43b

Please sign in to comment.