3

I'm looking to add some sort of HTTP push-like functionality, implemented via long polling or another standard means, to a page built with Perl on top of Apache.

Is there a way to do this without setting up a separate server such as Meteor or Stardust? Is there a module that would help with the server code? Is there a way other than long polling?

brian d foy
  • 129,424
  • 31
  • 207
  • 592
justkt
  • 14,610
  • 8
  • 42
  • 62
  • 1
    I don't think this is possible with Apache because it requires a completely different architecture to handle server push. – mpeters Nov 04 '10 at 20:41
  • @mpeters - research is proving you right... – justkt Nov 05 '10 at 16:50
  • Is this via CGI? If so, look into nph- If not, server push should be pretty easy with mod_perl. – Leolo Nov 06 '10 at 19:55
  • 1
    OK, short bit of research shows up that Apache is a very poor match for long polling. But look into mod_handoff if you can't migrate your entire project to another web server. – Leolo Nov 06 '10 at 20:04

1 Answers1

2

If your need a quick and dirty fix to avoid major changes to your current application or design, and you do not need instant updates, then one simple approach is to use regular AJAX polling from the browser to the server.

In other words you would have javascript in your browser check the server every couple of seconds to see if there is any message and/or data on the server for this browser session. This will most likely not scale very well, especially with short poll timeouts, and will eat up server resources, but it may be a useful stopgap solution.

Just to reiterate, this is just a quick fix workaround - general consensus is you need to use COMET (probably on a separate server in your case) as a proper solution (until websockets arrive...) - see some good analysis in these links:

http://cometdaily.com/2007/11/06/comet-is-always-better-than-polling/ http://stackoverflow.com/questions/2975290/comet-vs-ajax-polling

Mick
  • 24,231
  • 1
  • 54
  • 120
  • since this was the only feasible option I found, it's the answer. Thanks. Some day the architecture will get upgraded... – justkt Nov 16 '10 at 14:33