| 83 | }; |
| 84 | |
| 85 | const storeFileInSWCache = async (blob) => { |
| 86 | try { |
| 87 | performance.mark('start-sw-cache-cache'); |
| 88 | const modelCache = await caches.open('models'); |
| 89 | await modelCache.put('model.bin', new Response(blob)); |
| 90 | performance.mark('end-sw-cache-cache'); |
| 91 | const mark = performance.measure( |
| 92 | 'sw-cache-cache', |
| 93 | 'start-sw-cache-cache', |
| 94 | 'end-sw-cache-cache' |
| 95 | ); |
| 96 | console.log( |
| 97 | 'Model file cached in sw-cache.', |
| 98 | mark.name, |
| 99 | mark.duration.toFixed(2) |
| 100 | ); |
| 101 | } catch (err) { |
| 102 | console.error(err.name, err.message); |
| 103 | } |
| 104 | }; |
| 105 | |
| 106 | const storeFileHandleInIDB = async (handle) => { |
| 107 | try { |