pwa-module icon indicating copy to clipboard operation
pwa-module copied to clipboard

Is there any way to disable precaching entirely?

Open nathanchase opened this issue 4 years ago • 2 comments
trafficstars

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 avatar Sep 24 '21 17:09 nathanchase

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.

nathanchase avatar Sep 24 '21 17:09 nathanchase

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.

Tragio avatar Jun 29 '22 08:06 Tragio