Posted about 2 years ago. Visible to the public. Repeats.

Be careful to use correct HTTP status codes for maintenance pages

When your public-facing application has a longer downtime for server maintenance or long migrations, it's nice to setup a maintenance page to inform your users.

When delivering the maintenance page, be very careful to send the correct HTTP status code. Sending the wrong status code might get you kicked out of Google, or undo years of SEO work.

Here are some ways to shoot yourself in the foot durign maintenance:

  • If all your routes send a "200 OK" with a HTML body "We're back soon", Google will index "We're back soon" as the text for all your URLs.
  • If all your routes send a "404 Not Found", Google will remove all your URLs from its index.
  • If all your routes send a "301 Moved Permanently" with a redirect to /maintenance, that /maintenance will be the only path left in the Google index. Also browsers will cache the redirect forever.

Appropriate status code for maintenance pages

The best HTTP status code for your maintenance page is "503 Service Unavailable":

The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.

If you absolutely need to implement your maintenace page as a redirect to /maintenance (discouraged), make sure to use 302 Found to signal a temporary redirect.

If you want to be a super cool HTTP citizen you might also send:

Copy
Retry-After: 3600

This signals agents to retry after one hour.

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Henning Koch
Last edit:
about 2 years ago
by Henning Koch
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more