Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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 (wiki.nginx.org/HttpUpstreamModule#.24upstream_cache_status) and make an if-block including your exception. –  Jens Bradler May 8 '12 at 12:24

Your Answer

 
discard

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.