This could be a more general question, related to web architecture.

I'm developing a web application using ruby on rails, with jQuery to implement some AJAX requests and other funny slide effects.

Now i'm trying to figure out how to implement a "publish-subscrive" service.

It's difficult to explain it, maybe an example is better:

on facebook, when a friend of you put a comment on your state, you can see it, without the refreshing of the page.

I need something similar: when someone else create a new item of an entity, the server ask the client to add this new item in a table (for example).

The problem is that I don't think it could be done, because the server cannot contact the client (if the client hasn't start the connection with a server, through a GET-POST request, for example)... but facebook does it ;-) so i'm trying to learn how to do a similar thing.

A possible idea could be a javascript function, called every 1 second, that contact the server (through AJAX for example) for checking if there's a new "item"...
But it isn't so efficient.

Do u know how I can do it? Any suggestions?

Thanks guys!