Skip to content

Commit

Permalink
Add root URL to cache in SW.tsx and sw.js
Browse files Browse the repository at this point in the history
  • Loading branch information
m7medVision committed Jan 22, 2024
1 parent 4c00e3a commit 4e8664e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion islands/SW.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function SW() {
await caches.delete(key)
}
const cache = await caches.open("cache-v1")
await cache.addAll(data)
await cache.addAll([...data, "/"])
showToast({
msg: "تم تحميل الدروس بنجاح",
type: "info",
Expand Down
8 changes: 4 additions & 4 deletions static/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ self.addEventListener('install', async function (event) {
})
);
const resp = await fetch('/sw-cache.json');
const FILES_TO_CACHE = await resp.json();
const data = await resp.json();
caches.open(CACHE_NAME).then(function (cache) {
return cache.addAll(FILES_TO_CACHE);
return cache.addAll([...data, "/"]);
})

});
Expand All @@ -30,8 +30,8 @@ self.addEventListener('activate', function (event) {
event.waitUntil(
caches.open(CACHE_NAME).then(async function (cache) {
const resp = await fetch('/sw-cache.json');
const FILES_TO_CACHE = await resp.json();
return cache.addAll(FILES_TO_CACHE);
const data = await resp.json();
return cache.addAll([...data, "/"]);
})
);
});
Expand Down

0 comments on commit 4e8664e

Please sign in to comment.