title: Stopping requests server-side
body: <p>I've got a name lookup box that operates by your typical ajax requests.  Here's the general flow of the Javascript that fires every time a letter is pressed:</p>
  
  <ul>
  <li>If ajax request already open, then abort it.</li>
  <li>If timeout already created, destroy it.</li>
  <li>Set new timeout to run the following in half a second:</li>
  <li>Send string to 'nameLookup.php' via ajax</li>
  <li>Wait for response</li>
  <li>Display results</li>
  </ul>
  
  <p>The issue is that nameLookup.php is very resource heavy.  In some cases up to 10,000 names are being pulled from an SQL database, decrypted, and compared against the string.  Under normal circumstances requests can take anywhere from 5 to 60 seconds to return.</p>
  
  <p>I completely understand that when you abort a request on the client side the server is still working on things and sends back the result.  That it's just the client side that knows to ignore the response.  But the server is getting so hung up on working on all of these requests.</p>
  
  <p>So if you do:</p>
  
  <ul>
  <li>Request 1</li>
  <li>Abort Request 1</li>
  <li>Request 2</li>
  <li>Abort Request 2</li>
  <li>Request 3</li>
  <li>Wait for response from Request 3</li>
  </ul>
  
  <p>The server is either not even working on Request 3 until it's finished with 1 and 2... or it's just so hung up on working on Request 1 and 2 that Request 3 is taking an extra long amount of time.</p>
  
  <p>I need to know how to tell the server to stop working on Request 1 and 2 so I can free up resources for it to work on Request 3.</p>
  
  <p>I'm using Javascript &amp; jQuery on the client side.  PHP/Apache and SQL on the server side.</p>