Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use ngx_http_proxy_module with proxy_ignore_client_abort to cache files. So when client close connection nginx will continue copying file from backend to current server.

But when another user will try to get this file (which is still copying) nginx will go to backend to get new copy of file and will try to cache it too.

I can use proxy_cache_lock to prevent it. But it is bad idea, because file can be very large and it will get much time to wait while file will be cached.

How can I tell nginx to read this temporary file and not wait until the file is cached?

share|improve this question

You are looking for delivering a stale object of the cache. This can be done in case of an error, timeout to the back-end or while updating.

proxy_cache_use_stale updating error timeout;
share|improve this answer
Hm. It will use stale cache file if exists. But when there is no cache file (only tmp) it won't pass tnp file :) – fl00r May 7 '12 at 10:06
You can check the upstream_cache_status ( and make an if-block including your exception. – Jens Bradler May 8 '12 at 12:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.