Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

PWA: serve web app manifest network-first so Android registers the share target

Murtaza Nasir8f638bf1f117
diff --git a/static/sw.js b/static/sw.js
index a15f7a4f..0a865208 100644
--- a/static/sw.js
+++ b/static/sw.js
@@ -218,6 +218,18 @@ self.addEventListener('fetch', (event) => {
return;
}
+ // The web app manifest must NEVER be served stale. Android/Chrome re-reads
+ // it to (re)register the PWA's share_target (and file_handlers, shortcuts,
+ // etc). Cache-first pins whatever manifest was cached at first install —
+ // e.g. one from before share_target existed — so the Android share sheet
+ // never gains "Speakr" as a target no matter how many times the manifest
+ // is updated server-side. Serve it network-first: fresh from the network,
+ // falling back to cache only when offline.
+ if (url.pathname === '/static/manifest.json') {
+ event.respondWith(networkFirst(request));
+ return;
+ }
+
// For static assets listed in ASSETS_TO_CACHE, use cache-first.
// This ensures that if an asset path is directly requested, it's served from cache if possible.
// We need to match against the origin + pathname for ASSETS_TO_CACHE.