-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only caches visited routes #24
Comments
It is worth noting that I have my application set up as a single page app (SPA) |
I experience the same situation with a generated nuxt site. I wonder if the pwa-module could pre-cache the 200.html and fallback to this file in offline mode. AFAIK 200.html will either display the route if it exists, or show the custom error page if doesn't. |
#59 should fix it. |
@pi0 - I looked at the PR and I don't think it fixes the issue described here: With the PR #59 you can now disable runtime caching completely, so NO route is cached (only nuxt resources are cached). I think what this issues needs is to have ALL available routes be part of the precache. Therefore I vote for re-opening this issue. |
…ty#59) Make all-inclusive NetworkFirst route registration optional. Fixes nuxt-community#24.
I tested this again and to me it seems that the behaviour changed in the latest releases and it seems that the issue is now resolved and can be closed. Tested with: Nuxt 2.0.0 and @nuxtjs/pwa 2.6.0 The default behavior is now as follows:
To make my app work fully in offline mode, I added the following:
My configuration now looks like this:
If you don't set When I test this, a page previously not visited will return the contents, as the Nuxt fallback page will display the correct contents. If the page does not exist, Nuxt will evaluate the routes and show the 404 page design. |
@ahus1 You could also use the |
@ahus1 Happy to hear that it is finally working for you.😊 Enjoy coding and feel free opening new issues if you have observed any special problem. |
@pi0 I'm afraid this issue has to be reopened 😥 In the latest version (3.0.0-beta.20) the generated importScripts('https://cdn.jsdelivr.net/npm/workbox-cdn@4.3.1/workbox/workbox-sw.js')
workbox.setConfig({
"debug": false
})
workbox.core.clientsClaim()
workbox.core.skipWaiting()
workbox.precaching.cleanupOutdatedCaches()
workbox.routing.registerRoute(new RegExp('http://localhost:8000/api/public/.*'), new workbox.strategies.NetworkFirst ({}), 'GET')
workbox.routing.registerRoute(new RegExp('/_nuxt/'), new workbox.strategies.CacheFirst ({}), 'GET')
workbox.routing.registerRoute(new RegExp('/'), new workbox.strategies.NetworkFirst ({}), 'GET') I downgraded the @nuxtjs/pwa module to version 2.6 to see the following importScripts('/_nuxt/workbox.4c4f5ca6.js')
workbox.precaching.precacheAndRoute([
{
"url": "/_nuxt/12a3dce2a6e949590390.js",
"revision": "8ea362e53faf6466c89d4eac3f533e2a"
}
// ... (other fragments)
], {
"cacheId": "my-app",
"directoryIndex": "/",
"cleanUrls": false
})
workbox.clientsClaim()
workbox.skipWaiting()
workbox.routing.registerRoute(new RegExp('/_nuxt/.*'), workbox.strategies.cacheFirst({}), 'GET')
workbox.routing.registerRoute(new RegExp('/.*'), workbox.strategies.networkFirst({}), 'GET')
workbox.routing.registerRoute(new RegExp('http://localhost:8000/api/public/.*'), workbox.strategies.networkFirst({}), 'GET') So as you'd expect all routes are working offline in version 2.6 whereas in the latest version no precaching takes place and only the first route is cached on runtime. workbox: {
runtimeCaching: [
{ urlPattern: `${process.env.BACKEND_URL}/api/public/.*` }
]
} |
I'm not sure if an issue I'm having is the same regression, but I have had to add the following workaround which seems contrary to the docs.
The relevant part of the docs.
Without the custom
I have not added an |
I'm having same problem with version 3.0.0-beta.20. For now, I had to downgrad to 2.6 to work. I need to be precached and not in runtime caching. |
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. |
Same issue in 3.3.5 |
I'm facing the same limitation (not problem). I configured nuxt like this:
With network off, when I access a previously accessed route without it works fine. But when i access a route that I never entered it gives me the offline error. No problem, this is the expected behavior. I vote for re-opening this discussion. |
@pi0 any news on this? I'd like to know as well if there is a strategy/configuration for nuxt pwa to be able to offline/precache a SSG website (all routes). |
I'm facing the same exact issue with unvisited routes not being cached. |
Same issue in 3.3.5, no news? |
Is there been anyone who configured this with success? Tried several approaches, but still no luck. |
same I cannot get it to work, I got the router to respond, but does not know what to do with the route |
@RodrigoReyes-vw I have the same problem and fix it. You can see the issue. I hope it is useful to you. |
I've been playing around with the workbox component of the pwa module for a couple of days and have got it working with my hosting environment, but I seem to have a configuration problem.
For some reason only routes that I visit are being cached and then available offline. As far as I am concerned, this is not offline support as trying to navigate to other routes produces a browser error page.
This is strange, as in the sw.js file I can see that all of the nuxt js files for each route are being precached. However, trying to navigate to a route that I didn't visit while online gives the standard browser error (even though the corresponding nuxt js file is cached).
Is this the expected behaviour or is my configuration incorrect?
The text was updated successfully, but these errors were encountered: