Next.js SSR Setup Logging Multiple Functions When URL Params Passed #131
-
Switched from ISR to SSR with cache headers set to reduce the amount of function calls. ISR calls 2-3 per page request for uncached pages. SSR calls only one and with cache enabled it won't create a new function call for each page request. The issue is, if url params are passed in, for instance /page-name?utm_campaign=9999 it considers it as a new page and makes a new function call. I'm just making a getServerSideProps call, not using any router logic. Is there a way to change this so that it only makes one function call regardless of the url query params? |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 1 reply
-
I heard from Vercel support: Any parameter will cause the page/route's cache to be invalidated as the same page with each parameter is currently considered as a unique page/route. I asked them if there is a way to remove the params from the url before a function is called: It works locally but when tested on production it runs into an infinite redirect. It appears this is an open bug: vercel/next.js#32480 |
Beta Was this translation helpful? Give feedback.
I heard from Vercel support:
Any parameter will cause the page/route's cache to be invalidated as the same page with each parameter is currently considered as a unique page/route.
It's on the road map to provide improved functionality related to this.
I asked them if there is a way to remove the params from the url before a function is called:
This may be possible with Edge functions but would require testing to see if the cache invalidation happens before or after edge functions come into play.
You can give it a shot here:
https://vercel.com/docs/concepts/functions/edge-functions
It works locally but when tested on production it runs into an infinite redirect.
It appears this is an open …