drkbpwk609294 2010-07-13 21:31
浏览 8
已采纳

对于新闻热门网站,服务器重新加载页面有哪些好方法?

Which good ways exists to reload front page by server every time that new article placed by editor in front page for (news popular website like fox.com, cnn.com)?

Thanks

  • 写回答

3条回答 默认 最新

  • douping1825 2010-07-13 21:38
    关注

    You are looking for some asynchronous client/server communication.

    • You can either periodically poll the server (query it every x time unit), can result in wasted queries (in form of HTTP requests) and subsequently waste bandwidth, if lots of polls find no new data.
    • Or use what has been dubbed as "server push" which leaves an HTTP connection open for the server to push the updates back to the browser, without polling.

    GWT and GWT-RPC:

    Since you are on Java, I recommend you have a look at GWT, will simplify your "AJAX" work with its GWT-RPC. In GWT you use Java language on both the server-side and the client-side (compiled to JavaScript), and will handle all the implementation details on the asynchronous communication under the hood.

    To do the polling here, you can have a timer on the client-side (on the webpage) that will call a method that you have written on the server to give the data, can either be a String that represents some news, or even encapsulate it into a News class, with title, summary, body, and timestamp etc. The News class will then have to be in a shared (between client and server) Java package, so the implementation can be used on both sides without having you duplicating code.

    GWT Comet:

    This gwt-comet library provides an efficient Comet implementation for GWT.

    The library implements Comet by streaming messages over long lived HTTP requests to minimise latency and bandwidth requirements and maximise the throughput. This is opposed to many other implementations which use polling or long polling techniques.

    http://code.google.com/p/gwt-comet/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 如何实验stm32主通道和互补通道独立输出
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题