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?
10
There are several methods for this:
- Web Sockets
- Long Polling (or the blanket term Comet)
For solutions, check out:
- django-socketio
- 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.
3