开发者

HTML notification: What to do on server-side

开发者 https://www.devze.com 2022-12-21 10:15 出处:网络
I am interested in doing a stackoverflow type 开发者_开发技巧notification on my website. I know there are a few questions on this topic, but all of them are concerned with the client side css and ajax

I am interested in doing a stackoverflow type 开发者_开发技巧notification on my website. I know there are a few questions on this topic, but all of them are concerned with the client side css and ajax.

I would like to know the best way to handle things on the server side (jsp). I want to notify all users currently using the system that the server will be going down. So I can make a db with all the necessary information, and when the record is set to active, out comes the notification div. First question, is this the best way to handle this portion?

The next part is, how do I actually get the notification out. The only solutions I have thought of are to be polling from the web site with jQuery or to only check when pages are loaded. I know there are some push like things (comet, reverse ajax) but have no experience with these. Would these be useful in this situation, or would they be overkill? Is polling (pretty simple) the best way to go?


I would approach this from a separate angle. If you were to give more notice, say 30 minutes, then just worry about displaying the message on page load. If someone's loading a page so infrequently that they don't see this message, chances are polling isn't going to help most of that audience either. I'd say that the polling approach will just result in a lot of wasteful hits on your website 99% of the time it seems.


I would say that one possible middle ground for you would be to piggyback off of other ajax requests. So instead of polling, take the opportunity to intercept a request that the user was doing for some other reason, and include some piece of information about the db going down. You could put this in the response body, or even a cookie or http header.

0

精彩评论

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