Invalidating the service worker cache

After using useUpdate to modify a resource, the list view resends the GET request, but it still gets intercepted by the service worker, causing the UI to remain unchanged until I perform a full refresh. Even manually using useInvalidate doesn't get around the service worker. Any ideas on how to work around this?
3 Replies
rising-crimson
rising-crimson2y ago
Hi @khalibloo, Welcome to our community 🙏 refine has no implementation of ServiceWorker. so useInvalidate() has no information about ServiceWorker. This is expected behavior. What does your ServiceWorker implementation look like? Did you use any library? If you can provide more detailed information, we can think solution together 👊
metropolitan-bronze
metropolitan-bronze2y ago
I used the default NextJS setup with the superplate cli to setup the project. The network inspector in the browser indicated that the response was coming from the service worker not the API. But I took a closer look after seeing your message. I think the service worker might have come from other projects I had run previously on localhost:3000 I deleted the service workers. Now the network inspector no longer says "service worker", and it seems that I'm hitting the API. I'm still getting an outdated response, but now I suspect it's the cache I have on my API. Let me take a look at that and see if it helps. Yup, removing the API's cache fixed the issue. So I guess it was a combination of a service worker from a previously run app, and the API's own cache that caused it. Thanks very much
rising-crimson
rising-crimson2y ago
I'm glad the problem is solved 🙏