title: Suggestions on keeping connections alive with FTP file listing via AJAX?
body: <p>I have a multi-user Ruby on Rails web application that can interact with an FTP server via AJAX. The application allows the user to browse an FTP site. Javascript makes an AJAX call which communicates with a server-script that returns a list of files and directories within a given directory.</p>
  
  <p>This works fine. However, each time a directory listing is requested, the server must re-establish a connection with the FTP server, which takes a lot of time. I'm looking for a way to leave the FTP connection open for until some number of timeout seconds.</p>
  
  <p>I could probably do this using threads (though, I'm completely open to other ideas) or some fancy connection-pooling scheme (perhaps via a daemon that manages this).</p>
  
  <p>What are some ways I could persist and regain reference to connections in my ruby source?</p>
  
  <p>Someone suggested using a "Connection: Keep-Alive" header, but I don't see how that would help in this case.</p>