Strategy: cache only
This commit is contained in:
20
public/sw.js
20
public/sw.js
@@ -61,12 +61,18 @@ self.addEventListener("activate", function (event) {
|
||||
|
||||
// Strategy: cache with network fallback
|
||||
|
||||
// self.addEventListener("fetch", (event) => {
|
||||
// event.respondWith(
|
||||
// caches.open(CACHE_STATIC_NAME).then((cache) => {
|
||||
// return cache.match(event.request).then((res) => {
|
||||
// return res || fetch(event.request);
|
||||
// });
|
||||
// }),
|
||||
// );
|
||||
// });
|
||||
|
||||
// Strategy: cache only
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
event.respondWith(
|
||||
caches.open(CACHE_STATIC_NAME).then((cache) => {
|
||||
return cache.match(event.request).then((res) => {
|
||||
return res || fetch(event.request);
|
||||
});
|
||||
}),
|
||||
);
|
||||
event.respondWith(caches.match(event.request));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user