Replies: 2 comments
-
|
I have the exact same setup as you, and I'm also running into the same question now, where seemingly all that remains is overcoming the |
Beta Was this translation helpful? Give feedback.
-
|
You can use If your routes don't have client loaders, you could also prefetch |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I'm looking to support offline in my React Router 7 framework mode app. I have a service worker setup with Workbox. I looked at Vite PWA, but it seemed like using Workbox directly was the best option.
I disabled lazy route discovery in react router config to avoid
/__manifestrequests during navigation:I have the app shell cached with the workbox config:
Then in the service worker:
That appears to cache all of the clientside JS and CSS so that the only major remaining responses to cache are the .data responses from route loader functions.
The issue I'm having is that the .data requests, which are from
<Link />components, nearly always (always?) include a?_routes=search param which is a comma separated list of routes.I'm unsure what the best way is to cache these .data requests ahead of time. Currently, I'm using Workbox's NetworkFirst strategy to cache .data requests. In order to cache them as quickly as possible I'm using the
<Link />component withprefetch="render"which renders prefetch links in the header with the appropriate .data links with?_routes=.I don't mind this approach, but it does require that in order to cache a view for offline it needs to have a corresponding
<Link />rendered in the document.Is there a way to cache these responses without needing a
<Link />with aprefetchattribute?Beta Was this translation helpful? Give feedback.
All reactions