Set staleTime in the loader?
Is there a way to set the staleTime from inside the loader?
Depending on the params/searchParams I'd like to set a different staleTime.
Here's my use case, and I'm open to other ways of achieving it!
- I have a basic search page
- When a search query is entered, I want to cache the results for 10 minutes
- When there is no search query specified, I want to show random results, but would like to display new random results every time
In my mind, this translated to:
- If search query: staleTime = 10min
- else: staleTime = 0
1 Reply
fair-roseOP•4mo ago
I've considered using the loader to get actual search results, and fetching the random results in the component itself; but I'd like to keep all data loading in the loader if possible.