开发者

Best Practise of Making notifications for logged in user

开发者 https://www.devze.com 2022-12-15 12:51 出处:网络
I am making a web-site , which is a social network. There is need of making ov开发者_运维技巧erall notification block/bar on the website.

I am making a web-site , which is a social network. There is need of making ov开发者_运维技巧erall notification block/bar on the website.

User should be notified when a) there is new message b) there is new friend request c) there is new photo rating ....

As application (php/mysql) should be made with future calculation of minimum 100-1500 users online, what is the best practise to make such notificaion display? Should I make checks with each time users refresh their browser, or Jquery script which will ping the special check.php script each 10-15-20min...??? What is most professional practise ? Who can help?


There are 3 things that come to mind.

1) You could try using this "push" server which holds open a connection between the browser and the APE server and pushes information to the browser when needed. Check out the APE

2) You could open up a ajax connection to the web server and make it loop. You can then check server side if there are some new notifications and if there are, then you'll "push" it (even though it's a pull :-)) to the client and kill the script. If there are no new notifications, then you'll make the script sleep for X seconds and try again.

3) This I think is the worst idea. You can use setInterval() in Javascript to make the client check for new notifications (via pulling) every X seconds. Every check makes a new http connection, which isn't really good.

0

精彩评论

暂无评论...
验证码 换一张
取 消