Skip to main content
1 of 2
Eric Guan
  • 325
  • 1
  • 2
  • 7

Pushing data from Server to Client without a client request?

I've noticed while browsing stack overflow that there are dynamic notifications like "3 new messages, click to show". I want to have this kind of dynamic updating for what i'm about to explain.

Let's say i want to create a carousel/slideshow of 10 recent news articles. I want this carousel to be updated hourly, in a queue. Newer articles will push older articles out of the queue. The solution off the top of my head would be.

  1. User logs on to client.
  2. Client calculates # of minutes until next hour mark and sets a timer to execute at the hour.
  3. At hour mark, send a request to the server about any new news articles that haven't been in the carousel already.
  4. Handle response.
  5. Reset timer.

Is this an acceptable strategy? Can I achieve this without relying on client requests? In other words how does stack overflow achieve it's dynamic updating?

Thanks.

Eric Guan
  • 325
  • 1
  • 2
  • 7