aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/sw/sw.ts
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-06-15 14:14:28 +0800
committercrupest <crupest@outlook.com>2021-06-15 14:14:28 +0800
commit47587812b809fee2a95c76266d9d0e42fc4ac1ca (patch)
treebfaa7320c838e21edf88b5a037263f89a8012222 /FrontEnd/src/sw/sw.ts
parentda26373c7fc13cded47428b27638b349b0432437 (diff)
downloadtimeline-47587812b809fee2a95c76266d9d0e42fc4ac1ca.tar.gz
timeline-47587812b809fee2a95c76266d9d0e42fc4ac1ca.tar.bz2
timeline-47587812b809fee2a95c76266d9d0e42fc4ac1ca.zip
...
Diffstat (limited to 'FrontEnd/src/sw/sw.ts')
-rw-r--r--FrontEnd/src/sw/sw.ts62
1 files changed, 0 insertions, 62 deletions
diff --git a/FrontEnd/src/sw/sw.ts b/FrontEnd/src/sw/sw.ts
deleted file mode 100644
index 724804dd..00000000
--- a/FrontEnd/src/sw/sw.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import { precacheAndRoute, matchPrecache } from "workbox-precaching";
-import { registerRoute, setDefaultHandler } from "workbox-routing";
-import {
- NetworkFirst,
- NetworkOnly,
- StaleWhileRevalidate,
-} from "workbox-strategies";
-import { CacheableResponsePlugin } from "workbox-cacheable-response";
-import { ExpirationPlugin } from "workbox-expiration";
-
-declare let self: ServiceWorkerGlobalScope;
-
-self.addEventListener("message", (event) => {
- if (event.data && (event.data as { type: string }).type === "SKIP_WAITING") {
- void self.skipWaiting();
- }
-});
-
-precacheAndRoute(self.__WB_MANIFEST);
-
-const networkOnly = new NetworkOnly();
-
-registerRoute(new RegExp("/swagger/?.*"), new NetworkOnly());
-
-registerRoute(new RegExp("/api/token/?.*"), new NetworkOnly());
-registerRoute(new RegExp("/api/search/?.*"), new NetworkOnly());
-
-registerRoute(
- new RegExp("/api/users/.+/avatar"),
- new StaleWhileRevalidate({
- cacheName: "avatars",
- plugins: [
- new CacheableResponsePlugin({
- statuses: [200],
- }),
- new ExpirationPlugin({
- maxAgeSeconds: 60 * 60 * 24 * 30 * 3, // 3 months
- }),
- ],
- })
-);
-
-registerRoute(
- new RegExp("/api/?.*"),
- new NetworkFirst({
- plugins: [
- new CacheableResponsePlugin({
- statuses: [200],
- }),
- ],
- })
-);
-
-setDefaultHandler((options) => {
- const { request } = options;
-
- if (request instanceof Request && request.destination === "document")
- return matchPrecache("/index.html").then((r) =>
- r == null ? Response.error() : r
- );
- else return networkOnly.handle(options);
-});