Using "if -f" to return 503 for maintenace: good or bad?

IlyaK nginx-forum at
Sun Jul 15 23:42:10 UTC 2012


Sometimes I need to regenerate my website. I do not want my users to see
semi-generated site. I also do not want google to see 404 errors.

The best solution is to return "503" for while I my system generates new
files. Is not it?

So I want my system to put special "lock" file before generating content
and to remove it after it. 

And I put onto my server config: 

if (-f $document_root/lock ) {
    return 503;

Is my solution OK or is it bad? If so, what is the best solution? 
Probably I can configure nginx to establish TCP connection to my system
(permanent connection) and to show 503 in case of connection is
That should be better because we would not need to check filesystem each


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

More information about the nginx mailing list