Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to design an application where users can make posts with Django on the backend. Right now I have to refresh the page with JavaScript every 20 or 30 seconds to check for new posts that might be available for that page. I was wondering if there are more effective ways to do this? Maybe with a JSON response? I am looking for a solution like Twitter, where they show how many new posts are available that are not on the page or even like on Facebook where they update the wall posts automatically.

Is there a particular technology should I be researching in order make the updates more efficient?

share|improve this question
StackExchange pages don't refresh themselves automatically, but they do get notifications when they have new content available, so the user can choose to display it. Have a look at the JS involved and see if you can't pick up some ideas... :) – Mason Wheeler Feb 5 '13 at 19:11
I believe what you're looking for is Comet or long polling technique. – toy Feb 5 '13 at 19:18
If you're using Python – toy Feb 5 '13 at 19:18
@MasonWheeler Yes that's exactly what I am looking for. I would defiantly have a look into it. So is using js for this the right approach or is there a better and easier solution? – Jonathan Feb 5 '13 at 19:18
@toy looking into it now – Jonathan Feb 5 '13 at 19:20

There are several methods for this:

  1. Web Sockets
  2. Long Polling (or the blanket term Comet)

For solutions, check out:

  1. django-socketio
  2. Not a django implementation, but a great resource for concepts: SignalR

I would recommend going the websockets route, then falling back to long polling. Here's a fairly scholarly article on long polling and best practices.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.