Skip to content

Using cached useLoaderData from previous request. #810

Closed Answered by sergiodxa
chadmmills asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@chadmmills
Comment options

@matmilbury
Comment options

Answer selected by chadmmills
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants