<LINK> Prerender a url with query Params - Doesnt cache correctly - NextJS13

328 Views Asked by At

I'm trying to use To pre-request the next page using buttons on my website. The buttons just make a GET request with query params, so the server should process them and return different results(E.g. Places that are open, or closed).

E.g. 'Open now' will make a GET to: url.com/?open-now 'Closed' will make a GET to: url.com/?closed-now etc.

I'm able to predict the buttons query params, so i was hoping I could use LINK to prefetch those GET request and cache it, so when the user clicks, a server request is not made in real time since its already pre-fetched and cached.

However, I noticed that NEXTJS itself appends a extra query param to the url. I think this means, when nextJS checks its cache, it does find a match: E.g. The actual prefetched URL i can see in the networks tab shows the URL as: url.com/?closed-now&_rsc=6swst

You can see this is different to the actual URL when the user clicks, of url.com/?closed-now

Thus I THINK it misses on a cache check.

Is there any way to prevent this? I think NEXTJS is doing this internally within it's inner workings, but it means I can't prefetch a url from a element that contains with query params & prefetch/cache it?

I assume people may have the same issue with pagination, i.e. query param maybe: url.com/products?page=1

Since NEXTJS 13 will append this weird stuff to the end and may confuse the server, or, just simply not cache(what im experiencing)

Thanks

I was expecting my browser to show network GET requests to the URL i added into the

However, the network tab shows its appending some random text to the end thus possibly failing to cache?

0

There are 0 best solutions below