Need advice for beginner web developer. Building user notification system

94 Views Asked by At

web guru and all who interested,

I've built simple web application where users can post, comment, favourite articles and right know I've the idea to create a users notification system. At the beginning really simple: notify if user's post was favourited or commented. And I wonder what are the best practices and strategies for making it and of course the easiest way? I've read about web sockets technology, but not sure is this that I need for such simple functionality. Another idea is to make AJAX call let's say every 60s, taking user's ID and search if there's any new records in DB containing that ID. But I'm quite doubtful about efficiency of frequent calls to my server.

I believe you've got the idea and will advise me. Thanks in advance!

1

There are 1 best solutions below

0
On

Unless I'm reading it wrong, it sounds like what you're after is way to do a real time server event push to the browser.

In the past this was accomplished by either long polling or some other type of hack to do with keeping connections open or periodically opening connections (say every 10 seconds).

Now with HTML5 websockets and SSE (Server Side events) such hacks aren't necessary.

If all you want is one way (ie server to client) communication then you want to use SSE. http://www.html5rocks.com/en/tutorials/eventsource/basics/

Browser support is good and non-adherence can be polyfilled. Here is a list: https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills#eventsource

Hope this helps as a concept to get you started...