Open prstwo opened 1 year ago
@prstwo api
requests will NOT be cached on first navigation, workbox needs to create the cache and cannot be done when intercepting the requet, so cache will be activated on next navigation, just try reopening the url in a new browser instance.
Beware, if https://api.faresbazar.com/api-frontend/*
isn't in the same origin, you will need to handle opaque requests:
access-control-allow-origin: *
or custom one http header to all app responses (html,js)cacheableResponse: { statuses: [0, 200] }
to your api cache optionspurgeOnQuotaError: true
in expiration plugin options
runtimeCaching: [{
urlPattern: 'https://api.faresbazar.com/api-frontend/*',
handler: 'NetworkFirst',
options: {
cacheName: 'my-api-cache',
expiration: { maxEntries: 500, maxAgeSeconds: 60 * 60 * 24, purgeOnQuotaError: true },
cacheableResponse: { statuses: [0, 200] }
}
}]
Remember to also include some offline handle logic when using nuxt fetch stuff (check error and use VueUse::useOffline
in the logic).
Same issue here. Nothing above is working
hi, Thanks for your great plugin. I have challenge with caching api requests. vite-pwa/nuxt is installed on a nuxt 3 project and data is fetched based on api reqest. I want whenever a user get offline, page data get data from the cached api. Although all static files and components are cached successfully, api requests are not cached. this is url of the website: And here is the config of pwa in nuxt.config.js file: