title: How to get nginx to retry a static file if it doesn't exist
body: <p>I have an application server that generates image thumbnails with the URLs handled as static resources by nginx.  Currently this is a synchronous process, so the image is there when the request comes through.</p>
  
  <p>The nginx config for the images is straightforward:</p>
  
  <pre><code>location /image/cache/ {
      alias /var/www/image/cache/;
  }
  </code></pre>
  
  <p>However, rather than making the application block, I was hoping to generate the URL, but asynchronously generate the corresponding file, freeing up the app server.  The problem then becomes one of dealing with an image request in nginx for which there might not <em>yet</em> be a file.</p>
  
  <p>Is there a way to configure nginx to wait and retry on static resources that aren't there yet?</p>
  
  <p>An alternative might be to wire up an application call to ensure that the file is returned when it's available, I'm open to ways of doing that too.</p>