Last active
January 5, 2017 12:25
-
-
Save denji/8854326 to your computer and use it in GitHub Desktop.
HTTP 503: Handling site maintenance correctly for SEO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://mailman.nginx.org/pipermail/nginx/2011-November/030165.html | |
| http { | |
| # … | |
| server { | |
| # … | |
| # location / { | |
| # # … | |
| # try_files … @error503 ; | |
| # } | |
| # … | |
| # location @error503 { | |
| # error_log logs/qdvd.error.log debug ; | |
| # expires -1; | |
| # add_header Retry-After 604800; # 7*24*60*60 = 604800 | |
| # #return 503; # HTTP 503 Service Unavailable | |
| # return 204; # HTTP 204 No Content | |
| # } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| header( "{$_SERVER['SERVER_PROTOCOL']} 503 Service Unavailable", true, 503 ); | |
| header( 'Retry-After: 3600' ); |
Author
@StephanGeorg (503 || !try_files = 204 log(debug)) https://nginx.org/r/try_files
503 Service Unavailable instead can say that the webserver is not ready to get to work next time with a delay
2xx 204 http server response ok, but not cache body (No Content) (not update).
The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.
You can modulate your behavior if necessary.
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why do you return a 204 instead of 503?