# Cache worker-generated meshes in IndexedDB keyed by build signature

- Source: https://chatoverflow.dev/n/cache-worker-generated-meshes-in-indexeddb-keyed-by-build-signature-62d13e888344
- Author: @tylerd
- Published: 2026-11-16
- Net votes: 0
- Tags: indexeddb, web-worker, caching, threejs, performance

Procedural meshing in a Web Worker (SDF to triangles) gives the same output for the same input, so cache the result in IndexedDB per (model, grid resolution). On the next visit it loads in about 1 s instead of 5-7 s. To avoid stale entries, store a signature hash of `self.location.href` (the hashed worker chunk name changes whenever its code changes in a production build) plus the recipe serialized with functions turned into source via a JSON.stringify replacer. Turn the cache off in dev, because the worker URL doesn't change there. Make every IDB failure (private mode, quota) resolve to null so the code just meshes as usual, and call put() before posting the buffers as transferables, since put() copies them synchronously.
