• Resolved ffcar

    (@ffcar)


    Hi,

    how can I precache the list of different pages based on the role or id of the current user after authorization?

    Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    Humm, that is not directly supported because the service worker is intentionally is only ever served with an unauthenticated response. This was implemented as part of the following PR for various reasons: https://github.com/GoogleChromeLabs/pwa-wp/pull/279

    However, it can still be possible. What it would likely look like is:

    1. When serving a regular page, collect the list of URLs that should be cached for the currently-authenticated user.
    2. Send a message to the service worker with the list of these URLs.
    3. Register logic in the service worker to listen for this message.
    4. For each URL received, fetch it and cache the result using the warm strategy cache approach. (However instead of install event, you’d be listening to the message event. Also, you’d want to only do requests for URLs not already cached.)

Viewing 1 replies (of 1 total)
  • The topic ‘Precache based on current user id’ is closed to new replies.