Search code examples
web-applicationshttp-status-code-404data-driven

In a database driven web app, what should the user see when the database is unavailable?


If a web application relies on a database to serve dynamic content and that content is unavailable for whatever reason (database server down, etc.), what is the preferred method for handling this scenario?

  1. Redirect the visitor to a custom 404 page?
  2. Display the page anyway but include some sort of error message where the content would otherwise be?
  3. Display a related page that has static content?
  4. Other?

I understand that proper error logging should occur as well as notifying the webmaster and/or sysadmin. I'm mostly interested in best practices for what the end user should see in this situation.


Solution

  • #3 if you can (e.g. a snapshot of dynamic content taken every 20 mins), but make it crystal clear that it's static content as of <time> and will be refreshed as soon as system issues are resolved.

    #2 if you can not, as long as the error is human readable and not a literal re-print of an exception's stack trace from Java or somesuch.