Skip to content

Commit 13e6dca

Browse files
committed
Get rid of service worker, it makes caching complicated and is apparently not needed for PWAs anymore
1 parent e5f1a01 commit 13e6dca

File tree

3 files changed

+5
-35
lines changed

3 files changed

+5
-35
lines changed

frontend/public/static/sw.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

frontend/src/map/map.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ if (import.meta.hot) {
1414
});
1515
}
1616

17-
if ('serviceWorker' in navigator && location.hostname !== "localhost") {
18-
navigator.serviceWorker.register('./_app/static/sw.js', { scope: "./" }).catch((err) => {
19-
console.error("Error registering service worker", err);
20-
});
17+
if ('serviceWorker' in navigator) {
18+
// Uninstall legacy service worker
19+
navigator.serviceWorker.getRegistrations().then(async (registrations) => {
20+
await Promise.all(registrations.map((r) => r.unregister()));
21+
}).catch((err) => { console.warn("Error unregistering service worker", err); });
2122
}
2223

2324
setLayerOptions({

server/src/webserver.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ export async function initWebserver(database: Database, port: number, host?: str
9393
}
9494
});
9595

96-
app.use(`${paths.base}static/sw.js`, (req, res, next) => {
97-
res.setHeader("Service-Worker-Allowed", "/");
98-
next();
99-
});
100-
10196
app.use(`${paths.base}oembed`, async (req, res, next) => {
10297
const query = z.object({
10398
url: z.string(),

0 commit comments

Comments
 (0)