Best practices with realtime data / websockets. Send vs. revalidate data

14 views Asked by At

I'm building a real time chat app and as I understand it, realtime solutions like websockets/pusher can be used in at least two main ways:

  1. Pass events without data and revalidate fetches/cache
  2. Pass events with data and use that data on the page. i.e. Pass message in event and add it to the page when handling the event.

To me, I'm leaning towards the first approach since it's much simpler and more straightforward relative to the second one, but I'm wondering which approach is used more in practice and what the pros/cons of each approach would be in production apps.

0

There are 0 answers