Using cached useLoaderData from previous request. #810
-
Hello! Question around navigation and revisiting existing routes with data loaders… apologies if this has already been mentioned / addressed somewhere. If I have these two pages/routes - |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You can use the Cache-Control header on the response of the route-a loader to cache it in the user browser or a CDN, you can use this header doing stale while revalidate too (SWR name came from the header actually), so the CDN will return cached data and revalidate in the backend, next time someone request the data it will be updated (and it will be revalidated again). Combine that with something like useRevalidate to trigger a revalidation of the loaders a second after the page load and the data will update. |
Beta Was this translation helpful? Give feedback.
You can use the Cache-Control header on the response of the route-a loader to cache it in the user browser or a CDN, you can use this header doing stale while revalidate too (SWR name came from the header actually), so the CDN will return cached data and revalidate in the backend, next time someone request the data it will be updated (and it will be revalidated again).
Combine that with something like useRevalidate to trigger a revalidation of the loaders a second after the page load and the data will update.