vite-plugin-pwa: runtimeCaching for Videos returned with 206

Hey, currently I am working on a simple Demo Page with some Images and Videos on it. (I am using this small project as a POC)

I am working with Nuxt3 and configured the PWA in my Nuxt config (see below)

So I managed to cache the images with the Service Worker, but the Videos won’t work correctly. While trying to cache the Videos, the Browser returns: Uncaught (in promise) TypeError: Failed to execute 'put' on 'Cache': Partial response (status code 206) is unsupported

So I added “rangeRequest: true”, but that still didn’t fix it.

Is there a way to do this?

Thanks for your help

My Config:

export default defineNuxtConfig({
   //...
  modules: [
    '@vite-pwa/nuxt',
    //....
  ],
  
  nitro: {
    prerender: {
      routes: [ '/' ]
    }
  },

  pwa: {
    devOptions:{
      enabled: true
    },
    manifest: false,
    registerType: 'autoUpdate',
    injectRegister: 'auto',
    workbox: {
      globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
      runtimeCaching: [
        {
          urlPattern: /^https:\/\/videos\.pexels\.com\/.*/i,
          handler: 'CacheFirst',
          options: {
            cacheName: 'pexels-video-cache',
            expiration: {
              maxEntries: 500,
              maxAgeSeconds: 60 * 60 * 24 * 365 // <== 365 days
            },
            cacheableResponse: {
              statuses: [0, 200, 206]
            },
            rangeRequests: true
          }
        },
        {
          urlPattern: /^https:\/\/images\.pexels\.com\/.*/i,
          handler: 'CacheFirst',
          options: {
            cacheName: 'pexels-image-cache',
            expiration: {
              maxEntries: 20,
              maxAgeSeconds: 60 * 60 * 24 * 365 // <== 365 days
            },
            cacheableResponse: {
              statuses: [0, 200]
            }
          }
        }
      ]
    }
  }
})

I tried also handler: NetworkFirst and configuring a manifest won’t even change anything. I am Using Chrome Version 131.0.6778.70 (Official Build) (arm64) on macOS Sequoia V15.1 While testing, I am using Incognito windows, so there are no extensions or other stuff blocking. I also tried everything on localhost while running dev and deployed on CF pages as well.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

thats true @piotr-cz I think it’s more workbox related Thanks for your help guys!