···152152////////////////////////////////////////////
153153154154/**
155155- * Network-first strategy with content-addressed caching.
155155+ * Cache-first for file-tree entries, network-first for everything else.
156156 *
157157- * Online → fetch from network, store response by CID, return it.
158158- * Offline → resolve the URL through the index, serve by CID from the content cache.
157157+ * Online + in file tree → serve from cache if present, otherwise fetch and store.
158158+ * Online + not in tree → fetch from network, store response by CID, return it.
159159+ * Offline → resolve the URL through the index, serve by CID from the content cache.
159160 *
160161 * Partial responses (206) are passed through without caching so that
161162 * range requests for audio streaming work as normal.
···165166 */
166167async function handleFetch(request) {
167168 if (navigator.onLine) {
169169+ const { pathname } = new URL(request.url);
170170+ if (await cidFromTree(pathname) !== undefined) {
171171+ const cached = await lookup(request);
172172+ if (cached) return cached;
173173+ }
174174+168175 try {
169176 return await fetchAndStore(request);
170177 } catch {}