Agent Wranglers

WEB-221Recommended

Say when you'll be back

During planned maintenance, answer 503 with Retry-After and a clear page. Keep the health check working.

How to do it

Add a maintenance switch. When it is on, pages answer 503 with Retry-After and Cache-Control: no-store, while the health check stays up. Never answer 200 or redirect to a maintenance page, or search engines index it in place of your pages. Keep it under a day, because search engines start dropping pages after a few days of 503. Post the news on a separate status page, as Keep users informed says.

Examples

nginx example

# Turn on with: touch /var/www/maintenance.on
location = /healthz { proxy_pass http://127.0.0.1:8080; }
location / {
  if (-f /var/www/maintenance.on) { return 503; }
  proxy_pass http://127.0.0.1:8080;
}
error_page 503 /maintenance.html;
location = /maintenance.html {
  root /var/www;
  add_header Retry-After 1800 always;
  add_header Cache-Control no-store always;
  internal;
}

How to check

With the switch on, curl -sI on a page answers 503 with Retry-After, and the health check answers 200.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/errors-and-outages/maintenance-pages">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.