1
0
forked from maik/IPFS-portal

fix: sw.js POST cache error + manifest icon refs

This commit is contained in:
maikrolf
2026-06-29 16:19:16 +02:00
parent a8a9d33f36
commit b12b3e35f4
2 changed files with 15 additions and 13 deletions
+6 -6
View File
@@ -10,21 +10,21 @@
"categories": ["utilities", "productivity"],
"icons": [
{
"src": "/icon-192.png",
"src": "/icon-192.svg",
"sizes": "192x192",
"type": "image/png",
"type": "image/svg+xml",
"purpose": "any maskable"
},
{
"src": "/icon-512.png",
"src": "/icon-512.svg",
"sizes": "512x512",
"type": "image/png",
"type": "image/svg+xml",
"purpose": "any maskable"
},
{
"src": "/icon-512.png",
"src": "/icon-512.svg",
"sizes": "512x512",
"type": "image/png",
"type": "image/svg+xml",
"purpose": "maskable"
}
]
+9 -7
View File
@@ -1,4 +1,4 @@
/* ── IPFS Portal — Service Worker v2 ──
/* ── IPFS Portal — Service Worker v3 ──
*
* Cache strategieën per route type:
* - Precache: app shell (alle pages)
@@ -7,9 +7,9 @@
* - Stale-while-revalidate: navigatie requests
*/
const CACHE = 'ipfs-portal-v2';
const STATIC_CACHE = 'ipfs-portal-static-v2';
const DATA_CACHE = 'ipfs-portal-data-v2';
const CACHE = 'ipfs-portal-v3';
const STATIC_CACHE = 'ipfs-portal-static-v3';
const DATA_CACHE = 'ipfs-portal-data-v3';
const PRECACHE_URLS = [
'/',
@@ -103,7 +103,8 @@ async function cacheFirst(request, cacheName) {
if (cached) return cached;
try {
const response = await fetch(request);
if (response.ok) {
// Cache API supports GET/HEAD only
if (response.ok && request.method === 'GET') {
const cache = await caches.open(cacheName);
cache.put(request, response.clone());
}
@@ -116,7 +117,8 @@ async function cacheFirst(request, cacheName) {
async function networkFirst(request, cacheName) {
try {
const response = await fetch(request);
if (response.ok) {
// Cache API supports GET/HEAD only — POST/PUT/DELETE must be skipped
if (response.ok && request.method === 'GET') {
const cache = await caches.open(cacheName);
cache.put(request, response.clone());
}
@@ -134,7 +136,7 @@ async function staleWhileRevalidate(request, cacheName) {
const fetchPromise = fetch(request)
.then((response) => {
if (response.ok) cache.put(request, response.clone());
if (response.ok && request.method === 'GET') cache.put(request, response.clone());
return response;
})
.catch(() => cached);