nuxt-community / pwa-module

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

fix: offline page precaching due to revision query parameter #511

Open SebastienTainon opened 2 years ago

SebastienTainon commented 2 years ago

Hello, Since PR #386 was merged (and possibily a new version of workbox), the offlinePage option of the documentation does not seem to work. This is because since this PR, the cache identifier for the offline page now contains a WBREVISION query parameter: image When we do caches.match() it tries to get the page without the query parameter and so it gets nothing.

The workbox precaching module documentation page explains how to fix this:

Alternatively, if all you need is the precached Response object, you can call matchPrecache(), which will automatically use the correct cache key and search in the correct cache:

const response = await matchPrecache('/precached-file.html');

This is what I'm doing in this PR, since we already precache the offlinePage.