« Smerity.com

404 Marketing backed by Programming Zen

When rewriting the core blog engine of my site, I came to a strange Zen like programming realisation...

Traditionally, if a user is lost, they receive a 404 Not Found page. If, however, they are looking for the 404 Not Found page, then they found the page they were looking for.

Hence, 404 should return the HTTP status code 404 Not Found unless they're looking for the 404 page, in which case the HTTP status code should be 200 OK.

Are you mad?

To be fair, it would not be the first time I've lost my mind, but at least one site backs me up in this! The 404 page over at GitHub returns 200 OK when visited directly.

smerity@hermes:~$ curl -I https://github.com/404
HTTP/1.1 200 OK
Server: nginx/1.0.4
Date: Mon, 28 Nov 2011 16:07:31 GMT
Content-Type: text/html
Content-Length: 17461
Last-Modified: Mon, 28 Nov 2011 04:30:43 GMT
Connection: keep-alive
Accept-Ranges: bytes

If this is repeated for another page that is legitimately Not Found then the server returns 404 Not Found.

This website also obeys the 404 Zen rule, though only due to the static nature of the site. This website resides on GitHub Pages and as such is entirely static. To have a 404 page, you must provide 404.html. As 404.html is a genuine file, it makes sense to return 200 OK when it is directly requested.

Less Mad, Even Logic

If you believe the adage "Always be marketing", these error pages represent opportunity. Google and other search engines won't traditionally index 404s or other errors though. By returning 404 Not Found you're telling it, point blank, that the page contains no value and was caused by an error either by the server or the client. GitHub error pages contain aesthetic value

GitHub's error pages both have aesthetic value (a Star Wars themed octocat and a Wile E. Coyote style octocat) and have received interest from the tech community. As they return 200 OK, the links from the community positively impact their Google PageRank. Blippy's 404 an animated cow

Another example of the "Always be marketing" angle is Blippy's 404 page, which was covered on Tech Crunch and numerous other sites. They've made a major mistake if they're following that adage, however. As Blippy's 404 page returns 404 Not Found, it is not indexed by Google and contributes nothing to the site's PageRank.