How to avoid fetch deduplication or escape request context?
Unanswered
Roseate Spoonbill posted this in #help-forum
Roseate SpoonbillOP
Ok, this might be a bit long one, so bear with me:
I've a website with SSR-enabled live preview. Authorized requests starts ws client on the server, which connects to yjs websocket server (separate server). The process also needs to load some fresh data from backend CMS, with
Now to the problems:
-
- my ws client on the server belongs to the request, which started live preview, which not only impacts fetch behaviour, but also means, that I cannot revalidate tags, e.g. when web socket closes session.
Finally questions:
- Is server-side request context documented, so that I know what it impacts (e.g. that it groups fetch calls)? This is a main thing as I want to understand this mechanics better, but I'm struggling on finding any technical details.
- Can I have a ws client placed outside of page render request context? Ideally in a way that will still allow me to revalidate tags and paths.
PS to avoid questions around related things
- I tried
- I do know, that it won't work on serverless, for that I have a bit slower mode which simply pulls new data on refresh from live preview server with https call
- I do know setting up separate sidecar service is an option. I simply want to go with something I can easily copy between next projects without worrying about sidecar deployments.
I've a website with SSR-enabled live preview. Authorized requests starts ws client on the server, which connects to yjs websocket server (separate server). The process also needs to load some fresh data from backend CMS, with
cache: "no-store"
option.Now to the problems:
-
Some data fetches
mentioned before are done on ws events. It appears those are deduplicated and even if event comes with minutes between them, they return the same result, and request time suggest they return results from cache. Because fetch has cache disabled, I presume it's fetch deduplication cache. How to avoid it (outside of making fetch calls to api route handlers which do actual fetches)?- my ws client on the server belongs to the request, which started live preview, which not only impacts fetch behaviour, but also means, that I cannot revalidate tags, e.g. when web socket closes session.
Finally questions:
- Is server-side request context documented, so that I know what it impacts (e.g. that it groups fetch calls)? This is a main thing as I want to understand this mechanics better, but I'm struggling on finding any technical details.
- Can I have a ws client placed outside of page render request context? Ideally in a way that will still allow me to revalidate tags and paths.
PS to avoid questions around related things
- I tried
draftMode
, it's much slower, so I cannot use it for live preview, becaus I need rerenders to be snappy fast. Even if data sits in server memory and in cache, just enabling draft mode adds hundredts of ms to the refresh. - I do know, that it won't work on serverless, for that I have a bit slower mode which simply pulls new data on refresh from live preview server with https call
- I do know setting up separate sidecar service is an option. I simply want to go with something I can easily copy between next projects without worrying about sidecar deployments.