{
 "schema_version": 1,
 "generated": "2026-11-09",
 "id": "mlc-ai-web-llm--keep-the-model-loaded-across-pages-with-a-web-llm-service-wo",
 "repo": "mlc-ai/web-llm",
 "repo_url": "https://github.com/mlc-ai/web-llm",
 "repo_slug": "mlc-ai-web-llm",
 "title": "Keep the model loaded across page visits",
 "page_title": "How to keep the model loaded across page visits with Web LLM",
 "summary": "Run WebLLM in a Service Worker and pick a cache backend so the model is not reloaded on every visit and works better offline.",
 "who": "A developer shipping a multi page app or PWA with local AI.",
 "problem": "Reloading a multi gigabyte model on each page view is slow.",
 "outcome": "A service worker engine shared across pages, with model files cached in the browser.",
 "steps": [
  "Install with `npm install @mlc-ai/web-llm`",
  "In sw.ts instantiate ServiceWorkerMLCEngineHandler at the top level of the script",
  "Register the service worker in main.ts and create the engine with CreateServiceWorkerMLCEngine",
  "Optionally set AppConfig.cacheBackend to cache, indexeddb or opfs"
 ],
 "agent_prompt": "Using mlc-ai/web-llm, add a sw.ts with ServiceWorkerMLCEngineHandler, register it, create the engine with CreateServiceWorkerMLCEngine, and set cacheBackend to indexeddb.",
 "agents": [
  "claude-code",
  "codex",
  "cursor",
  "gemini-cli"
 ],
 "difficulty": "Advanced",
 "time": "2 hours",
 "basis": "readme",
 "caveat": "The README warns the browser can kill a service worker at any time, so add error handling.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "",
 "requirements": [
  "A browser with WebGPU support on a device with a capable GPU",
  "Node with npm, yarn or pnpm: `npm install @mlc-ai/web-llm`, or import from the jsdelivr CDN",
  "Bandwidth and storage for the first model download, which the README warns can take a significant amount of time"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.8,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/mlc-ai-web-llm/keep-the-model-loaded-across-pages-with-a-web-llm-service-wo/",
 "md": "https://dedupedai.com/use-cases/mlc-ai-web-llm/keep-the-model-loaded-across-pages-with-a-web-llm-service-wo/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/mlc-ai-web-llm--keep-the-model-loaded-across-pages-with-a-web-llm-service-wo.json",
 "api_version": "v1"
}
