Pwa-module: Only caches visited routes

Created on 23 Jul 2020  路  4Comments  路  Source: nuxt-community/pwa-module

Excuse me!

I'm making a Note App,

Notes is synchronized through websocket and written to IndexedDB with network,

Read historical notes from indexeddb without network,

But latest version 3.0.0-beta.20 only caches visited routes (2.6.0 it works)

1

I wish users to have access to all routes without a network, What do I need to do?

Thank you for your help (and #24)

Most helpful comment

Facing the same limitation. It would be good to have a precachedRoutes option like this:
precachedRoutes: ['/home', '/about', '/tasks']

So when the user access any one of this routes in offline it will render even if the user never entered before on this route.

All 4 comments

Having the same issue using v3.0.2.

I want to pre-cache some routes (if not all) so that even though the user may not have visited that route (page) while online, it would work offline.

nuxt.config.js

pwa: {
    workbox: {
        cacheNames: {
            prefix: "my-app",
            suffix: "v1",
            googleAnalytics: "test-ga"
        },
        offlineAssets: ["/400.png"],
        offlineAnalytics: true
    }
}

sw.js

// Precache assets

workbox.precaching.precacheAndRoute([
  "/400.png"
], {
  "cacheId": "APP-prod",
  "directoryIndex": "/"
})

// --------------------------------------------------
// Runtime Caching
// --------------------------------------------------

// Register route handlers for runtimeCaching
workbox.routing.registerRoute(new RegExp('/_nuxt/'), new workbox.strategies.CacheFirst ({}), 'GET')

There is no workbox.precaching.precacheAndRoute happening for routes!

I have the same problem, user must visit the route in online mode in order to be cached for future offline mode.

Hello,
did anyone find a solution?
Thanks :)

Facing the same limitation. It would be good to have a precachedRoutes option like this:
precachedRoutes: ['/home', '/about', '/tasks']

So when the user access any one of this routes in offline it will render even if the user never entered before on this route.

Was this page helpful?
0 / 5 - 0 ratings