Next.js Discord

Discord Forum

Sync ServerCache and ClientCache

Unanswered
Persian posted this in #help-forum
Open in Discord
PersianOP
Is there a good way to have a synced cache between next-client and next-server files?

I am trying to find something valid to go after, but it all seems to outdated information.

9 Replies

Longtail tuna
i'd say websockets, but since nextjs doesnt support them (still) you can use streams/sse
you can try https://www.npmjs.com/package/@upstash/realtime to emit cache stuff to client immediately
still you'd need to write cache logic
the way you are deploying your application probably does not
@Sun bear next.js does support websockets
Longtail tuna
sure it does if you are up to setup custom server and lose most of nextjs features
Sun bear
and what are those next.js features that you lose :D
Longtail tuna
as per docs
PersianOP
I have sat up a SSE system.

My idea was to set up a caching system and using SSE to update the cache in client.

I don´t want to build something that make the client able to send to server cachce (never trust the client)..

Would you say I am on the right path?