Web Cache API compliant implementation using the Origin Private File System (OPFS) to store responses. Useful for caching large responses such as Hugging Face models or any other large file that exceeds the typical caching quota’s of the browser.
npm install @p0u4a/opfs-cache
const blob = await response.blob();
await cache.put(new Request("https://example.com/path/to/file"), new Response(blob));
const response = await cache.match(new Request("https://example.com/path/to/file"));
const entries = await cache.keys();
await cache.delete(new Request("https://example.com/path/to/file"));
import { OPFSCache } from "@p0u4a/opfs-cache";
import { env } from "@huggingface/transformers";
const opfsModelCache = new OPFSCache("transformers-cache");
env.useBrowserCache = false;
env.useCustomCache = true;
env.customCache = opfsModelCache;