Cache loader data and Make your SSR app more stable and smooth: Add error retries and data caching to your server loaders. #13280
suhaotian
started this conversation in
Show and tell / tips
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When building SSR applications where the backend API is separate from the frontend, we need to fetch data inside React Router's loader functions for Pre-rendering.
Sometimes, fetching data fails due to network issues or high traffic when many users visit the same page at once. This can lead to multiple redundant requests on the server, especially when the data is large, causing performance issues.
To improve this, we can:
These enhancements make SSR applications more stable and efficient.
Instead of patching
fetch
, we can use a fetch wrapper with plugin support.Here, we use xior.js, which I built for this purpose:
This makes data fetching more reliable and efficient in SSR applications.
Hope these tips help! If you have any questions or issues, please leave a comment. More information check https://github.com/suhaotian/xior
Beta Was this translation helpful? Give feedback.
All reactions