You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cannot seem to get runtime caching to allow for caching of api data.
vite.config.js
import{defineConfig}from"vite";importComponentsfrom"unplugin-vue-components/vite";importvuefrom"@vitejs/plugin-vue2";import{VitePWA}from"vite-plugin-pwa";//Runtime CachingexportdefaultdefineConfig({alias: {"@": require("path").resolve(__dirname,"src"),},plugins: [vue(),Components(),VitePWA({//Runtimeworkbox: {runtimeCaching: [{urlPattern: "https://www.themealdb.com/*",// Adjust the URL pattern to match your API endpointhandler: "NetworkFirst",options: {cacheName: "mealDb",// Name for your cacheexpiration: {maxEntries: 500,maxAgeSeconds: 60*60*24,purgeOnQuotaError: true,},cacheableResponse: {statuses: [0,200]},},},],},strategies: "injectManifest",srcDir: "src",filename: "sw.js",injectManifest: {globPatterns: [// all packaged resources are stored here"assets/*",// add HTML and other resources for the root directory"*.{svg,png,jpg}","*.html",//"manifest.webmanifest",// be careful, not to add sw.js],},manifest: {name: "Test Project",short_name: "Test",theme_color: "#ffffff",id: "/",description: "Vue PWA ",display: "standalone",background_color: "#ffffff",icons: [{src: "/android-chrome-192x192.png",sizes: "192x192",type: "image/png",},{src: "/android-chrome-512x512.png",sizes: "512x512",type: "image/png",},{src: "/android-chrome-512x512.png",sizes: "512x512",type: "image/png",purpose: "any maskable",},],},}),],});
Those entries are the equivalent to your workbox.runtimeCaching handler: when using generateSW strategy, workbox-build will generate a registerRoute per plugin in the sw output.
In summary, when using generateSW workbox-build will be configured using workbox pwa plugin configuration entry; when using injectManifest strategy workbox-build will be configured using injectManifest pwa plugin configuration entry.
I really wish you guys wouldn't close the issue b4 confirmation that ur proposed solution is working, because it is not and now i will reopen it till i get a working solution
The text was updated successfully, but these errors were encountered:
Cannot seem to get runtime caching to allow for caching of api data.
vite.config.js
sw.js
Your proposed solution
@R0N1n-dev workbox-build only works in one mode, if you are using custom sw (injectManifest strategy), you MUST include runtimeCaching in your service worker logic, check this for example: https://github.com/elk-zone/elk/blob/main/service-worker/sw.ts#L56-L94
Those entries are the equivalent to your workbox.runtimeCaching handler: when using generateSW strategy, workbox-build will generate a registerRoute per plugin in the sw output.
In summary, when using generateSW workbox-build will be configured using workbox pwa plugin configuration entry; when using injectManifest strategy workbox-build will be configured using injectManifest pwa plugin configuration entry.
I really wish you guys wouldn't close the issue b4 confirmation that ur proposed solution is working, because it is not and now i will reopen it till i get a working solution
The text was updated successfully, but these errors were encountered: