Enable keep-alive in django for persistent connection

Enable keep-alive in django for persistent connection



I keep seeing references for keep-alive as a way to help maintain persistent connection, but I can't find any information on how to implement this with Django. How can I access this setting for Django? Thanks.


keep-alive




1 Answer
1



As described in this question: Keeping connection open in Django without websockets Django doesn't support this keep-alive header as it is mostly a request/response framework. However, unlike that question you don't mention not wanting to use websockets, so...


keep-alive



Websockets would be the way to have a persistent connection and there is a really nice library which adds this functionality to Django called Django Channels. Using this you can establish a persistent connection to the client and send data to the client without it constantly having to request new information. There's a great tutorial in the documentation and general research on websockets should yield some useful information as well.





Thank you very much. I'll read into Django Channels
– juju
Sep 5 '18 at 17:45



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.