-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Which project does this relate to?
Router
Describe the bug
When preloading a route (by hovering on a link for example), the preloaded data is kept in the cache for some time (default is 30 seconds) & no new requests will be made even when hovering on the same link again.
I noticed this behaviour doesn't work as expected when there's a layout in the preloaded route.
Check the reproduction example or the video below:
I've set the defaultStaleTime to 5 seconds, after those 5 seconds, every time I hover on the About link, the layout route loaded is invoked without being cached.
Recording.2025-05-08.150312.mp4
Your Example Website or App
https://stackblitz.com/edit/github-51knrjza-peyz37du?file=src%2Fmain.tsx
Steps to Reproduce the Bug or Issue
- Go to home page
- Wait for at least 5 seconds
- Hover over the 'About' link repeatedly and observe the console logs
- You will see the
Layout loadermessage appearing every time you hover on the link without any caching. (Where as theAbout loaderis cached properly)
Expected behavior
The expected behaviour is for the layout routes loaders to be cached like normal routes pages.
The docs don't specify any special treatment for layouts AFAIK.
Screenshots or Videos
Recording.2025-05-08.150312.mp4
Platform
- OS: Linux
- Browser: Chrome
- Version: 135
Additional context
No response