add clear caching

This commit is contained in:
sky
2025-11-04 22:09:32 -05:00
parent 51bac6f65f
commit 896b2a0133
3 changed files with 27 additions and 4 deletions

12
js/all.min.js vendored
View File

@ -9,7 +9,17 @@ loadAnalytics.unami = function() {
script.setAttribute("data-website-id", "cdb79ddd-06a6-478f-b726-be39b502d6a5"); script.setAttribute("data-website-id", "cdb79ddd-06a6-478f-b726-be39b502d6a5");
document.head.appendChild(script); document.head.appendChild(script);
}; };
loadAnalytics.cloudflare = function() {
// <script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "e5b0ef8807e74cef81287ac77bd18938"}'></script>
let script = document.createElement("script");
script.setAttribute("defer", "");
script.setAttribute("src", "https://static.cloudflareinsights.com/beacon.min.js");
script.setAttribute("data-cf-beacon", '{"token": "e5b0ef8807e74cef81287ac77bd18938"}');
document.head.appendChild(script);
};
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
loadAnalytics.unami(); // yo why are all analytic providers mid
// loadAnalytics.unami();
// loadAnalytics.cloudflare();
}) })

View File

@ -158,6 +158,18 @@
alert("not completed"); alert("not completed");
} }
} }
async function deleteAllCaches() {
try {
const cacheNames = await caches.keys();
await Promise.all(
cacheNames.map(cacheName => {
console.log(`Deleting cache: ${cacheName}`);
return caches.delete(cacheName);
})
);
} catch {}
}
</script> </script>
</head> </head>
<body> <body>
@ -208,10 +220,11 @@
</section> </section>
<section> <section>
<h2>manage data</h2> <h2>manage data</h2>
<p>not implemented</p> <p>download & upload currently unfinished, use the cloud backups</p>
<button id="downloadData">download</button> <button id="downloadData">download</button>
<button id="uploadData">upload</button> <button id="uploadData">upload</button>
<button onclick="wipeData()">wipe (erases all game data)</button> <button onclick="wipeData()">wipe (erases all game data)</button>
<button onclick="deleteAllCaches()">wipe all cache</button>
</section> </section>
</sections> </sections>
</body> </body>

4
sw.js
View File

@ -12,7 +12,7 @@ if(workbox) {
cacheName: 'images-cache', cacheName: 'images-cache',
plugins: [ plugins: [
new workbox.expiration.ExpirationPlugin({ new workbox.expiration.ExpirationPlugin({
maxEntries: 500, maxEntries: 600,
maxAgeSeconds: 365 * 24 * 60 * 60, maxAgeSeconds: 365 * 24 * 60 * 60,
}), }),
], ],
@ -37,7 +37,7 @@ if(workbox) {
cacheName: 'json-cache', cacheName: 'json-cache',
plugins: [ plugins: [
new workbox.expiration.ExpirationPlugin({ new workbox.expiration.ExpirationPlugin({
maxAgeSeconds: 24 * 60 * 60, maxAgeSeconds: 3 * 60 * 60,
maxEntries: 2, maxEntries: 2,
}), }),
], ],