MCPcopy Create free account
hub / github.com/GoogleChrome/samples / restoreFileFromSWCache

Function restoreFileFromSWCache

mediapipe-llm/script.js:175–200  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

173};
174
175const restoreFileFromSWCache = async () => {
176 try {
177 performance.mark('start-sw-cache-restore');
178 const modelCache = await caches.open('models');
179 const response = await modelCache.match('model.bin');
180 if (!response) {
181 throw new Error(`File model.bin not found in sw-cache.`);
182 }
183 const file = await response.blob();
184 performance.mark('end-sw-cache-restore');
185 const mark = performance.measure(
186 'sw-cache-restore',
187 'start-sw-cache-restore',
188 'end-sw-cache-restore'
189 );
190 console.log(
191 'Cached model file found in sw-cache.',
192 mark.name,
193 mark.duration.toFixed(2)
194 );
195 modelBlobURL = URL.createObjectURL(file);
196 return 'Service Worker Cache';
197 } catch (err) {
198 throw err;
199 }
200};
201
202const restoreFileFromFileHandle = async () => {
203 try {

Callers 1

initFunction · 0.85

Calls 2

openMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected