Route with/without querystring being treated as the same route
Unanswered
Brown bear posted this in #help-forum
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.
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
force-static
essentially disables searchParamshttps://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamic
Brown bearOP
Oh ok, do you know the solution?
Unfortunately not, but there is some client-side caching going on with searchParams at least. Example in gif
Brown bearOP
Thanks, i'll use SSR until i can find a cacheing solution
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
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