- storing changes for now
This commit is contained in:
16
src/utils/cacheSound.ts
Normal file
16
src/utils/cacheSound.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export async function getOrCacheBlob(url: string) {
|
||||
const cache = await caches.open("app-sounds-v1");
|
||||
const hit = await cache.match(url);
|
||||
if (hit) return await hit.blob();
|
||||
|
||||
const res = await fetch(url, { cache: "no-store" });
|
||||
if (!res.ok) throw new Error(`Fetch failed: ${res.status}`);
|
||||
await cache.put(url, res.clone());
|
||||
|
||||
return await res.blob();
|
||||
}
|
||||
|
||||
export async function evictFromCache(url: string) {
|
||||
const cache = await caches.open("app-sounds-v1");
|
||||
await cache.delete(url);
|
||||
}
|
||||
Reference in New Issue
Block a user