There is no guarantee that changes in DNS records will be picked up by all clients within the span of of the DNS TTL you set.
Ideally you use your load balancer to completely transparently show the maintenance page, rather than your normal web server(s) without any DNS changes.
In the absence of a loadbalancer:
If you can, rather than changing the DNS record and the IP-addresses for example.com
and www.example.com
consider temporarily assigning the current public IP-address used by your production server to a different server for the duration of you maintenance.
That switch is completely in your control and normally much quicker to effect than DNS changes.
When you can't ; don't hesitate to change the DNS.
On the web server that temporarily hosts example.com
and www.example.com
you can:
- Configure the webserver to return a transient error code for all requested resources and pages. So rather than a HTTP status 200, return a custom HTTP
503
"Service Unavailable" error page; ideally with a header Retry-after: time-stamp-when-maintenance-is-complete
and a nicely formatted page telling the same to human visitors.
That makes it clear to all browsers, indexers and visitors that the current content is not your actual website.
- Or alternatively configure a temporary catch-all redirect to for example
maintenance.example.com
; the HTTP 302
response and temporary redirects shouldn't be cached by browsers and shouldn't be indexed.
After maintenance, remove that redirect and you should be good
Either is configured in your webserver ; the syntax of course depends on the web server:
For apache httpd, create a subdirectory where you store your custom 503 maintenance page, css, images etc and exclude that subdirectory from the overall maintenance and the use a rewrite rule to trigger the 503 response for everything else: (untested)
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
Alias "/planned/maintenance/" "/path/to/maintenance-content/"
ErrorDocument 503 /planned/maintenance/index.html
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/planned/maintenance/
RewriteRule .* - [R=503,L]
<VirtualHost>