admin管理员组

文章数量:1295728

This problem is, if my page, that employs workbox-webstreams sents a request to the server, let say 3 streams hits the sever( NetworkFirst) and it has a redirect to a login page because session has expired, what I get is my page (the one that shoots the request) now have it mangeld with 3 login page html.

my question is, how can i isntruct workbox to abandon streaming and make a full page reload(or redirect)?

Well, one solutiion i tried, since i was using htmx, if the request was made by htmx (i.e not a navigation request), i can do a client side redirecting, which works but my problem is with navigation request via workbox (which employs webstream).

Below is an example of webstream with workbox, as you'll notice two of these stream hits the server first, if user sessions has expired, i get my page mangled with 2 login page.


export const dashboardPageStream = composeStrategies(
  [
    async ({ event }) =>
      staleWhileRevalidateStrategy.handle({
        request: new Request("/account/dashboard/openingHtmlTag-Partial.html"),
        event,
      }),
    async ({ event }) =>
      networkFirstStrategy.handle({
        request: new Request("/account/dashboard/commonHeader-Partial.html"),
        event,
      }),
    async ({ event }) =>
      cacheFirstStrategy.handle({
        request: new Request("/account/dashboard/mainOpeningTag-Partial.html"),
        event,
      }),
    async ({ event }) =>
      staleWhileRevalidateStrategy.handle({
        request: new Request("/account/dashboard/swiperOne"),
        event,
      }),
    async ({ event }) =>
      networkFirstStrategy.handle({
        request: new Request("/account/dashboard/echarts?month=0"),
        event,
      }),
    async ({ event }) =>
      staleWhileRevalidateStrategy.handle({
        request: new Request("/account/dashboard/swiperTwo"),
        event,
      }),
    async ({ event }) =>
      cacheFirstStrategy.handle({
        request: new Request("/account/dashboard/footer-Partial.html"),
        event,
      }),
    async ({ event }) =>
      staleWhileRevalidateStrategy.handle({
        request: new Request("/account/dashboard/closingHtmlTag-Partial.html"),
        event,
      }),
  ],
  {}
);

本文标签: Workbox webstreaming reacting to redirect from a substreamStack Overflow