drkbpwk609294
drkbpwk609294
2010-07-13 21:31

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

已采纳

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 douping1825 11年前

    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/

    点赞 评论 复制链接分享
  • dsnd7200 dsnd7200 11年前

    The poor man's alternative to AJAX (sheesh, does every two-bit Web site have to be Web 2.0 these days??) is simply inserting an HTML refresh command into the page. This is documented all over the Web; I Google for it whenever I need it, and keep forgetting how.

    It's dead simple and works even if the user has JavaScript disabled. On the downside, it does refresh the entire page.

    点赞 评论 复制链接分享
  • doushao1087 doushao1087 11年前

    What you want is an AJAX call on your front page that queries the server for new articles every few minutes and if the server returns a new article the Javascript should then display it to the page.

    点赞 评论 复制链接分享