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

Hello,

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
unavailable?
That should be better because we would not need to check filesystem each
time.

Thanks!

Posted at Nginx Forum:

Your solution is okay.

Thats the only way if you maintaince your site. Google will come back
again. And dont get an error 404 or else.

So your search index will not destroy.

Posted at Nginx Forum:

Hello,

a short question about nginx rewrite function. Is it possible
to rewrite a url like:

http://domain.com/486ab6c88fd112a89ccgdwd04a3d8275:8d27ce:1.jpg

to a path like:

/media/48/6a/486ab6c88fd112a89cc4d9d04a3d8275:8d27ce:1.jpg

i will use the first 4 characters of my filename as 2 subdirectories.
This was my test, but works not …

location / {
rewrite “^/([a-z0-9] {2})([a-z0-9] {2})([a-z0-9]+)$”
/media/$1/$2/$1$2$3
}

Is there a way i can debug such rewrite rules?

Thanks so much.

Elena

On Thursday 19 July 2012 03:06:51 Elena Z. wrote:
[…]

location / {
rewrite “^/([a-z0-9] {2})([a-z0-9] {2})([a-z0-9]+)$” /media/$1/$2/$1$2$3
}

rewrite “^/([0-9a-f]{2})([0-9a-f]{2})” /media/$1/$2$uri;

Is there a way i can debug such rewrite rules?

pcretest

wbr, Valentin V. Bartenev