0

I'm having an issue where my app is removing OK responses from the cache and returning 404 if the backend is down.

Currently, cache and revalidate time are the same.

I need to cache these requests until new data comes OK (i.e. HTTP 200).

React query has cache time and revalidate time as options, I'm wondering if I should put cache time to unlimited if possible, and revalidate with the normal 10 minutes time.

3
  • In queryFn, if the data is not as expected, throw an error. React Query will not update the cache if it throws. Commented Jun 20 at 22:39
  • @AhmedAbdelbaset I'm doing that right now, but today we experienced a 404 page (due to backend error) but then upon reload it was 200 OK. i.e. the page was cached as 404, served as 404, but revalidated in the background, and next page was 200 OK. Or maybe it was NextJS cache somehow?
    – JorgeeFG
    Commented Jun 21 at 2:14
  • React query doesn't cache pages or handle 404 pages itself. Your question needs more clarification Commented Jun 21 at 7:44

0

Browse other questions tagged or ask your own question.