-
-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to deal with not found assets for new deploying If we set dynamicStartUrl false. #267
Comments
I think to change the path "/" to StaleWhileRevalidate is required for this problem? {
urlPattern: "/",
handler: "StaleWhileRevalidate",
options: {
cacheName: "start-url",
expiration: {
maxEntries: 4,
maxAgeSeconds: 1
}
}
} |
@shadowwalker I wonder why with default settings dynamicStartUrl: true. It is different from the default next.js behavior. This is an example: https://stackblitz.com/edit/github-dn74e4?file=pages/about.js I think we shouldn't change this behavior with default settings when it works well for everyone. |
Hi, @meotimdihia ! For the doc
This was there to solve a particular problem with a common pattern. When a user sign in the web app, cookies is set and redirect back to home page. With SSR, server received the cookie and determined the user is signed in and render the HTML on server and send back a different HTML than the cached one. The option set to true solved the problem that user get confused after sign in and still see old HTML. You can play this use case using the https://github.com/shadowwalker/next-pwa/tree/master/examples/cookie example, just try turning this option off and see how things goes. |
@shadowwalker: But the problem "re-fetch" doesn't happen with other static pages but the static homepage. Its behavior is different from Next.js without PWA. |
I think what you have mentioned coming from here: Lines 51 to 56 in 54bbba6
And start url is defined here: Line 80 in 54bbba6
I'm not sure if I should change the logic here, as it was meant to solve the particular problem, and maintain the usability by default. Do you have any good suggestions how this should be implemented without breaking anyone? |
@shadowwalker Sorry, I don't really understand exactly how workbox works 😅.
|
The config const cache = require("next-pwa/cache")
cache.push({
urlPattern: "/",
handler: "StaleWhileRevalidate",
options: {
cacheName: "start-url", // CHANGE THIS TO start-url
expiration: {
maxEntries: 10,
maxAgeSeconds: 36400
}
}
})
pwa: {
dest: "public",
disable: process.env.NODE_ENV !== 'production',
// register: false,
// swSrc: 'service-worker.js',
buildExcludes: [/static\/media\/.*\.svg$/],
// runtimeCaching: cache,
dynamicStartUrl : false,
skipWaiting: true
} When I change the homepage, and it takes forever for the browser with an existing worker to update the new version page. I think StaleWhileRevalidate will update the cache after the first request? ...... Currently, the best way is to set |
We can reproduce the problem by these steps:
|
I solved this problem by updating: Line 80 in 67e4d58
with PWA config: pwa: {
runtimeCaching: [],
dynamicStartUrl : true,
} |
I close this issue since the patch solved it. |
Summary
When a new deploying and CDN cleared assets like JS, CSS. And the service worker still serves the old homepage version.
This is a screenshot:
Versions
next-pwa
: 5.2.24next
: 11.1.0Do we have a way to force service workers to delete the old version of the start page?
The text was updated successfully, but these errors were encountered: