From 41ab583e0dbeef0951ca2e4d866323725d745ead Mon Sep 17 00:00:00 2001 From: shrashiti Date: Sun, 14 Nov 2021 03:08:53 +0000 Subject: [PATCH] Introduce an cacheStartUrl configuration With cacheStartUrl users can decide if they want to cache or not startUrl. It is the same as dynamicStartUrl but with dynamicStartUrl serviceWorker will send a request extra. --- index.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 797c2342..ea6695f8 100644 --- a/index.js +++ b/index.js @@ -34,6 +34,7 @@ module.exports = (nextConfig = {}) => ({ sw = 'sw.js', dynamicStartUrl = true, dynamicStartUrlRedirect, + cacheStartUrl = true, skipWaiting = true, clientsClaim = true, cleanupOutdatedCaches = true, @@ -154,16 +155,18 @@ module.exports = (nextConfig = {}) => ({ })) } - if (!dynamicStartUrl) { - manifestEntries.push({ - url: basePath, - revision: buildId - }) - } else if (typeof dynamicStartUrlRedirect === 'string' && dynamicStartUrlRedirect.length > 0) { - manifestEntries.push({ - url: dynamicStartUrlRedirect, - revision: buildId - }) + if (cacheStartUrl) { + if (!dynamicStartUrl) { + manifestEntries.push({ + url: basePath, + revision: buildId + }) + } else if (typeof dynamicStartUrlRedirect === 'string' && dynamicStartUrlRedirect.length > 0) { + manifestEntries.push({ + url: dynamicStartUrlRedirect, + revision: buildId + }) + } } let _fallbacks = fallbacks