nuxt-community / pwa-module

Zero config PWA solution for Nuxt.js
https://pwa.nuxtjs.org
MIT License
1.24k stars 171 forks source link

Is there any way to disable precaching entirely? #489

Open nathanchase opened 3 years ago

nathanchase commented 3 years ago

I am noticing that the module will assign a precache of our app's /login page, because the homepage '/' is behind an authorization wall (using auth-module).

So what happens is that the workbox precache storage tries to load the /login page instead of the homepage '/' and it throws a 500 error.

If I delete the precache file from Cache Storage in the Chrome inspector, everything works fine.

I really just want to be able to prevent the pwa-module from precaching anything, but

pwa: {
    workbox: {
      preCaching: false,
    },
},

does not work. Is there any other option other than completely disabling the module?

Lines 75-78 in particular are what I want to disable: https://github.com/nuxt-community/pwa-module/blob/79322c18a28456a02ef0c3c596dff6cd88389f59/src/workbox/options.ts

  // Add start_url to precaching
  if (pwa.manifest && pwa.manifest.start_url) {
    options.preCaching.unshift(...normalizePreCaching(pwa.manifest.start_url))
  }
nathanchase commented 3 years ago

My workaround to get precaching to not occur was to simply remove start_url entirely in my manifest by explicitly setting to an empty string. Not '/', not removing the line from the manifest, but just '': start_url: ''

That prevented precaching, but the service worker still functions.

Tragio commented 2 years ago

Having the same issue with the latest PWA and Auth modules. Since I'm using a custom manifest I fixed it by removing 'start_url' line.