Next.js Discord

Discord Forum

Route with/without querystring being treated as the same route

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Avatar
Brown bearOP
I have a route "/search" which i have set to ISR cacheing via
export const dynamic = 'force-static';
export const revalidate = 60*60;

If i visit /search, it is cached. If i then visit /search?query=jobs, i am returned the page cache of /search. I want the route /search with unique querystrings to be treated as different routes so that each is individually cached.

6 Replies

Avatar
Mozzy
Avatar
Brown bearOP
Oh ok, do you know the solution?
Avatar
Mozzy
Unfortunately not, but there is some client-side caching going on with searchParams at least. Example in gif
Image
Avatar
Brown bearOP
Thanks, i'll use SSR until i can find a cacheing solution
Avatar
joulev & fuma pray for Schneider
No this is not possible. You either do full dynamic rendering with the searchParams prop, or do static rendering + client side fetching with the useSearchParams hook. It’s impossible to cache different queries as different pages
Avatar
Brown bearOP
Thanks for the confirmation Joulev I won’t look into it further. I prefer to keep this feature server side so I’ll stick with dynamic