Skip to content

Commit 403f45b

Browse files
committed
Fix serwist cache external tracking url issue
1 parent bcc2c3f commit 403f45b

3 files changed

Lines changed: 5 additions & 131 deletions

File tree

package-lock.json

Lines changed: 0 additions & 111 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525
}
2626
},
2727
"scripts": {
28-
"dev": "next dev --turbopack",
28+
"dev": "npm run clean:sw && next dev --turbopack",
2929
"build": "next build",
3030
"build:docker": "STANDALONE_BUILD=true next build",
3131
"start": "next start",
3232
"start:standalone": "node .next/standalone/server.js",
33-
"lint": "next lint"
33+
"lint": "next lint",
34+
"clean:sw": "rm -f public/sw.js public/sw.js.map public/swe-worker-*.js"
3435
},
3536
"devDependencies": {
3637
"@playwright/test": "^1.58.2",

sw/sw.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
/// <reference lib="webworker" />
22
import { defaultCache } from "@serwist/next/worker";
33
import type { PrecacheEntry } from "@serwist/precaching";
4-
import { installSerwist, type RuntimeCaching } from "@serwist/sw";
5-
import { NetworkOnly } from "serwist";
4+
import { installSerwist } from "@serwist/sw";
65

76
declare const self: ServiceWorkerGlobalScope & {
87
__SW_MANIFEST: (PrecacheEntry | string)[] | undefined;
98
};
109

11-
const customCache: RuntimeCaching[] = [
12-
{
13-
matcher: ({ request }) => request.mode === 'navigate',
14-
handler: new NetworkOnly(),
15-
},
16-
{
17-
matcher: ({ url }) => {
18-
const blockedDomains = ['px.ads.linkedin.com', 'www.googletagmanager.com', 'cmp.osano.com'];
19-
return blockedDomains.some(domain => url.hostname.includes(domain));
20-
},
21-
handler: new NetworkOnly(),
22-
},
23-
...defaultCache,
24-
];
25-
2610
installSerwist({
2711
precacheEntries: self.__SW_MANIFEST,
2812
skipWaiting: true,
2913
clientsClaim: true,
3014
navigationPreload: true,
31-
runtimeCaching: customCache,
15+
runtimeCaching: defaultCache,
3216
});

0 commit comments

Comments
 (0)