workbox-boardcast-update to show App update in react app

27 Views Asked by At

I am using workbox-boardcast-update in my service worker to track cache update.

I have my service worker as follows:

workbox.routing.registerRoute(
      ({ url }) =>
    url.pathname.includes("/home/") ||
    url.pathname.includes("/consultant/group/list/withConsultants"),

    new workbox.strategies.StaleWhileRevalidate({
    cacheName: "api_cache",
    plugins: [
      new workbox.broadcastUpdate.BroadcastUpdatePlugin({
        headersToCheck: ["Date", "date"],
      }),
      new workbox.cacheableResponse.CacheableResponsePlugin({
        statuses: [200],
        headers: {
          "content-type": "application/json;charset=UTF-8",
        },
      }),
     ],
     })
    );

However, I am getting this error in my console. enter image description here

I tried exposting the date header in reponse but the date header changes on every request which is not reliable for checking cache update. Are there other ways that I am unaware about? Please Help!!!

0

There are 0 best solutions below