Skip to content

Commit

Permalink
Introduce an cacheStartUrl configuration
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shrashiti authored Nov 14, 2021
1 parent 733ee35 commit 41ab583
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = (nextConfig = {}) => ({
sw = 'sw.js',
dynamicStartUrl = true,
dynamicStartUrlRedirect,
cacheStartUrl = true,
skipWaiting = true,
clientsClaim = true,
cleanupOutdatedCaches = true,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 41ab583

Please sign in to comment.