Rewrite_module patch: 'if (-z)' checks for zero-length files


I’ve a heavy loaded reverse proxy for large video files on
nginx/http_proxy_module. Sometimes I cache a zero-length file due to a
problem of the upstream server and it’s a headache for my client. I
found that, the “if” conditions of the rewrite module doesn’t support
checks based on file size, so I wrote some code for that, you can found
as a diff for 0.7.62 here: -It’s a
lightweight modification, I think it could go into mainline.

location / {

if (!-f $request_filename) { # damned empty cached files,

if (-z $request_filename) { # bye, bye! :slight_smile:
proxy_pass http://indavideo;

Thanks for your great work,

Roland Pallai
Sysadmin at

Posted at Nginx Forum:,13944,13944#msg-13944