shadowwalker / next-pwa

Zero config PWA plugin for Next.js, with workbox 🧰
MIT License
3.89k stars 325 forks source link

Introduce an cacheStartUrl configuration #296

Closed shrashiti closed 2 years ago

shrashiti commented 3 years ago

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.

meotimdihia commented 2 years ago

@shadowwalker it may be related to the issue that I posted: https://github.com/shadowwalker/next-pwa/issues/267#issuecomment-925835325 Please take a look at this request.

shadowwalker commented 2 years ago

@meotimdihia But this looks confusing to me. What use case that you don't want to cache start url?

meotimdihia commented 2 years ago

@meotimdihia But this looks confusing to me. What use case that you don't want to cache start url?

Thanks for looking into this issue. Service worker doesn't always install immediately to the browser. On some devices, I even take hours to install the new version. (Even months, I have seen it in the Sentry )

For example:

  1. Start URL/Homepage (cached) => request API https://examples/api/getIndex1 => render

  2. if you change the response structure or remove the API https://examples/api/getIndex1 and update homepage => deploy production.

  3. But Start URL/homepage was cached in user browser (waiting for new service worker version) => users will see a broken website here.

meotimdihia commented 2 years ago

Thanks for the merge.

mrafei commented 2 years ago

Hi, start_url is still being cached for my project. Even though I set cacheStartUrl: false. I'm on next-pwa 5.5.2 and next 12.1.6. Any suggestions how to fix? Thanks.

Capture

ArmenAivazian commented 2 years ago

Hi, start_url is still being cached for my project. Even though I set cacheStartUrl: false. I'm on next-pwa 5.5.2 and next 12.1.6. Any suggestions how to fix? Thanks.

Capture

add to the next.config.js field dynamicStartUrl: false

meotimdihia commented 2 years ago

@mrafei It works for me. You can follow these steps:

https://github.com/shadowwalker/next-pwa/issues/267#issuecomment-908151945

and yes, I think we have to use both cacheStartUrl and dynamicStartUrl