Support » Plugin: PWA » “Offline Browsing” Toggle and caching

  • Resolved simplistics.ca

    (@simplisticsca)


    So I may be confused in how I’m interpreting things, but I’m running into an issue with 302 redirects being cached by the service worker. I have the site in “network-first” mode as outlined in the plugin description. That is, the “offline browsing” checkbox is checked. Based on a previous response, I can see that this should show “Cache-Control: no-cache” in the request headers – which it does. However I’m still seeing in Chrome Web Tools, my requests are resolving as:
    200 (from service worker).

    My understanding is in network-first mode, I should only be seeing cached results when offline? The specific issue I’m having is: I have a page that should temporarily redirect based on a cookie (I’ve tried setting the redirect both as 302 and 307, same result). The problem is, after the cookie is cleared – the service worked seems to be continuing to serve that redirect, even in network-first mode. Am I misunderstanding something about the way it’s supposed to work? If I disable the PWA plugin it all works perfectly. I don’t have any other caching installed.

    Thanks in advance for your help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • To follow-up on this, I may have more info. I’m seeing the following console error:

    The service worker navigation preload request was cancelled before ‘preloadResponse’ settled. If you intend to use ‘preloadResponse’, use waitUntil() or respondWith() to wait for the promise to settle.

    Not sure if that’s related.

    Plugin Author Weston Ruter

    (@westonruter)

    It could be due to the timeout being reached for the network-first strategy. It’s by default 2 seconds. It may be the same issue described in https://wordpress.org/support/topic/cache-issues-14/

    The service worker navigation preload request was cancelled before ‘preloadResponse’ settled. If you intend to use ‘preloadResponse’, use waitUntil() or respondWith() to wait for the promise to settle.

    This has been reported before in the context of Workbox:

    https://github.com/GoogleChrome/workbox/issues/2883
    https://github.com/GoogleChrome/workbox/issues/2178

    I understand that could be a bug in Chrome that is resulting in this message being shown. Or it may be a bug in Workbox which may be resolved with an update. The current version of Workbox being used in the stable version of the PWA plugin is v5 whereas the latest version of Workbox if v6.

    Hi Weston,

    Thanks a ton for the reply – it is indeed related to that issue. The suggested fix of filtering the config to increase ‘network_timeout_seconds’ did the trick. Maybe a setting for that with a description is warranted in the plugin? Either way thanks a lot for the help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘“Offline Browsing” Toggle and caching’ is closed to new replies.