Skip to content
Discussion options

You must be logged in to vote

I think when you do frontend routing with next, it will still call functions like getInitialProps or getServerSideProps. The functions are usually self-contained, meaning the new QueryClient is created inside of it. That also means that the client is always empty, so the fetch from prefetch will always happen.

Some ways around this that I know of:

  • set a cache-control: max-age on the response with the time of caching that you want. That way, the request will be made, but it will not hit your server, but come from the browser cache instead. As an advantage, those fetches will also succeed while you're offline.
  • instruct next to not make the query if the request comes from a client transitio…

Replies: 1 comment 2 replies

Comment options

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

@TkDodo
Comment options

Answer selected by gammatitan
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