mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2025-08-08 04:39:16 +02:00
feat:#5 added own service worker script for precache api during install
This commit is contained in:
@@ -28,7 +28,13 @@ export default defineConfig({
|
||||
mode: "development",
|
||||
base: "/",
|
||||
injectRegister: "auto",
|
||||
includeAssets: ["favicon.ico", "apple-touch-icon.png", "mask-icon.svg"],
|
||||
includeAssets: [
|
||||
"favicon.ico",
|
||||
"apple-touch-icon.png",
|
||||
"mask-icon.svg",
|
||||
"robots.txt",
|
||||
"sitemap.xml"
|
||||
],
|
||||
manifest: {
|
||||
name: "HTWKalender",
|
||||
short_name: "HTWKalender",
|
||||
@@ -81,47 +87,6 @@ export default defineConfig({
|
||||
],
|
||||
},
|
||||
registerType: "autoUpdate",
|
||||
workbox: {
|
||||
globPatterns: ["**/*.{js,css,html,ico,png,svg,json,vue,txt,woff2}"],
|
||||
cleanupOutdatedCaches: true,
|
||||
runtimeCaching: [
|
||||
{
|
||||
urlPattern: ({ url }) => url.pathname.startsWith("/api/feed"),
|
||||
method: "GET",
|
||||
handler: "NetworkFirst",
|
||||
options: {
|
||||
cacheName: "calendar-feed-cache",
|
||||
expiration: {
|
||||
maxAgeSeconds: 12 * 60 * 60, // 12 hours
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
// Add the runtime caching strategy for /api/modules
|
||||
urlPattern: ({url}) => url.pathname.startsWith('/api/modules'),
|
||||
method: 'GET',
|
||||
handler: 'NetworkFirst',
|
||||
options: {
|
||||
cacheName: 'modules-cache',
|
||||
expiration: {
|
||||
maxAgeSeconds: 24 * 60 * 60, // 1 day
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
urlPattern: /^https?.*/,
|
||||
handler: "NetworkFirst",
|
||||
options: {
|
||||
cacheName: "https-calls",
|
||||
expiration: {
|
||||
maxEntries: 150,
|
||||
maxAgeSeconds: 30 * 12 * 60 * 60, // 1 month
|
||||
},
|
||||
networkTimeoutSeconds: 10, // fall back to cache if api does not response within 10 seconds
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
devOptions: {
|
||||
enabled: true,
|
||||
/* when using generateSW the PWA plugin will switch to classic */
|
||||
@@ -129,6 +94,7 @@ export default defineConfig({
|
||||
navigateFallback: "index.html",
|
||||
suppressWarnings: true,
|
||||
},
|
||||
strategies: "injectManifest",
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
|
Reference in New Issue
Block a user