Next-pwa: [question] additionalManifestEntries revision ID

Created on 5 May 2020  路  3Comments  路  Source: shadowwalker/next-pwa

in next.config.js custom configuration is there any way to get revision if we have provided additionalManifestEntries for precaching routes? or we can just randomly generate and provide it?

because providing null actilly caches it sorta permanantly and doesn't reflect changes after hard reload

Here's a sample behaviour on precache route with null as revision build id reverts back even after empty cache and hard reload
Peek 2020-05-05 17-17

All 3 comments

Same issue.
You can use some webpack plugin to pass revision id inside a custom service worker. This service worker you can later pass on to the workbox using injectManifest mode.

In my case there was no need of webpack plugin alteration, I just passed random revision ID on each build

additionalManifestEntries: [
  { url: "/", revision: RANDOM_ID }
]

@harshzalavadiya passing a random id would work, but best practice is using MD5 checksum for each file because it will help workbox understand the file is modified and need to update the cache.

This utility function is for that purpose:
https://github.com/shadowwalker/next-pwa/blob/502ed0c9e222bf8b1a5cb15676e566eed656c2f2/index.js#L11

Was this page helpful?
0 / 5 - 0 ratings

Related issues

loyep picture loyep  路  3Comments

flamedmg picture flamedmg  路  4Comments

Garlink picture Garlink  路  4Comments

paales picture paales  路  4Comments

paales picture paales  路  3Comments