title: NGINX : Making two asynchronously calls to a backend server
body: <p>I want to do the following using NGINX Module : 
  Nginx receives a request, checks if it has the key to decode the request in the cache(custom)</p>
  
  <ul>
  <li>if YES, then decode request, obtain an ID from it and check if there is a value against this ID in a key-value store (asynchronously) and return it in the response</li>
  <li>if NO, then get the new key from the key-value store (asynchronously) and then store this key in the cache and use it to decode the request. Obtain the ID and check if there is a value against this ID in the key-value store(asynchronously) and send it in the response.</li>
  </ul>
  
  <p>I was able to figure out how to do step 1, i wrote an upstream module by referring openresty's nginx module from <a href="https://github.com/openresty/redis2-nginx-module" rel="nofollow">github</a>. For achieving step 2 functionality, i tried creating a new upstream request in the process_header() function of the first upstream call (i.e getting the key from the store), but this didn't work. How to achieve this ?</p>
  
  <p>Thanks in advance.</p>