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
VitePWA({// https://vite-pwa-org.netlify.app/guide/registerType: 'autoUpdate',devOptions: {enabled: false},injectRegister: 'auto',workbox: {globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2,glb,json}'],// Files matching any of these patterns will be included in the precache manifest.maximumFileSizeToCacheInBytes: 15000000,// 15 MiBruntimeCaching: [{urlPattern: ({url }): boolean=>url.href.startsWith('https://www.domain.com/api/'),method: 'GET',handler: 'NetworkFirst',// Prefer making API request. If not possible (e.g. no network connection), fall back to cache.options: {cacheName: 'api-cache',cacheableResponse: {statuses: [0,200]// 0 = opaque responses, as defined in the Fetch API.},networkTimeoutSeconds: 10// Keep the timeout this high! Otherwise, workbox might be unable to respond with the cached version fast enough.}}]},[...]
When moving to a live server, we get a fetch failure. Looking into the requests, the service worker seems to trigger the browser to make a preflight request. It sends a OPTIONS request.
Most caching strategies don't cache OPTIONS requests, especially in scenarios like CORS preflight checks, as they are preflight verifications and don't carry the data or response you'd typically cache.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a caching config for an API GET request:
When moving to a live server, we get a fetch failure. Looking into the requests, the service worker seems to trigger the browser to make a preflight request. It sends a OPTIONS request.
Most caching strategies don't cache OPTIONS requests, especially in scenarios like CORS preflight checks, as they are preflight verifications and don't carry the data or response you'd typically cache.
Is that the case in VitePWA?
Beta Was this translation helpful? Give feedback.
All reactions