Important Note for Your Custom Error Pages

Just a note to web designers and code-savvy bloggers: make sure your custom error pages are big enough for the ever-amazing <cough> Internet Explorer browser. If your custom error pages are too small, IE will take the liberty of serving its own proprietary web page, replete with corporate linkage and poor grammar.

How big, baby?

Well, that’s a good question. In order for users of Internet Explorer to enjoy your carefully crafted custom error pages, they need to exceed 512 bytes in size. Using proper doctype markup, your custom pages should include more than around 10 lines (roughly) of additional markup and/or content. A good rule of thumb is to throw down at least a couple of decent-sized chunks of code. If you are going for a minimalist set of custom error pages and need a way to increase overall page size, you can always add a paragraph or two of good ‘ol Lorem Ipsum text as a comment in the markup:

<!-- Just for you, Microsoft! 
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque scelerisque. Donec euismod. Mauris eget pede es vel est tristique adipiscing. Integer in sem a enim molestie elementum. Curabitur elementum, nisl eu dapibus dapibus, libero tortor tincidunt quam, in facilisis arcu lacus ut diam. Nam ultricies felis sed felis. Integer interdum. Quisque iaculis porttitor magna. Fusce aliquet. Nulla felis dui, pulvinar at, rutrum in, fermentum eu, metus. Praesent purus nunc, porta vel, sodales id, fermentum eget, massa.
-->

Um, why?

Don’t ax me why Microsoft chose to implement this bizarre functionality in their browsers. They probably had a reason for doing so. As for why 512 bytes is useful to remember as a minimum page size for IE, let’s have a look at the following table, which shows the file sizes of IE’s default error pages for various HTTP error codes:

Code Description File Size
400 Bad Request > 512 bytes
403 Forbidden > 256 bytes
404 Not Found > 512 bytes
405 Method Not Allowed > 256 bytes
406 Not Acceptable > 512 bytes
408 Request Time-out > 512 bytes
409 Conflict > 512 bytes
410 Gone > 256 bytes
500 Internal Server Error > 512 bytes
501 Not Implemented > 512 bytes
505 HTTP Version Not Supported > 512 bytes

Apparently, IE is programmed to use these default pages if something bigger is unavailable — even if it is explicitly specified elsewhere. In other words, if Microsoft encounters a non-IE error page that is bigger than their own, it is recognized as a legitimate, deliberate alternative and thusly served. As to why Microsoft chose “file size” as the deciding factor, we may never know.

As we may see, there are actually several different minimum error-page file sizes, not just one. Nonetheless, the differences are practically negligible and hardly worth memorizing. Thus, we simply use the largest value as the minimum, and the others are automatically included. So, by ensuring that each of our various custom error pages is at least 512 bytes in size, we ensure that IE recognizes and serves them instead of their own, sad versions.

As always, any additional insight is greatly appreciated! :)